Content deleted Content added
m Reverted edits by 2409:4064:201F:1340:AD09:7874:51CF:2813 (talk) to last version by PCock |
simplify import/export example, remove information and references to identifiable persons |
||
Line 329:
Export example:
<syntaxhighlight lang="javascript">
/
//Export properties▼
export var name = 'Prashant Yadav';▼
}▼
export let age = 23;
// Export
export function add(num1, num2){
return num1 + num2;
}
// Export class
export class
constructor(num1, num2) {
this.num1 = num1;
this.num2 = num2;
}
add() {
return sum(this.num1
}
}
▲//This is private as we are not exporting it
▲ return width * height;
▲}
▲let square = (length) => {
</syntaxhighlight>
Import example:
<syntaxhighlight lang="javascript">
// Import
import { add } from './
console.log(add(1, 2)); // 3
// Import multiple properties
import { name, age } from './
console.log(name, age);
//>
// Import all
import * from './module.js'
console.log(name, age);
//> "Alice", 23
console.log(add(1,2));
//> 3▼
▲// 3
</syntaxhighlight>
|