-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodule.js
More file actions
43 lines (34 loc) · 1.3 KB
/
Copy pathmodule.js
File metadata and controls
43 lines (34 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//Named Imports
//import { add } from './math.js';
import { add, subtract, PI } from './math.js';
// Import all named exports from math.js
import * as math from "./math.js";
import {name,age} from './person.js';
import {name as name2,age as age2} from './person2.js';
// Import all named exports from person.js
import * as person from "./person.js";
//Default Import
import message from './message.js';
import text from './message.js';
let result = add(2, 3);
console.log(`The result of adding 2 and 3 is: ${result}`);
result = subtract(5, 2);
console.log(`The result of subtracting 2 from 5 is: ${result}`);
console.log(`The value of PI is: ${PI}`);
console.log(`Using math module to multiply 4 and 5: ${math.multiply(4, 5)}`);
console.log(`Using math module to divide 20 by 4: ${math.divide(20, 4)}`);
console.log(`The value of PI is: ${math.PI}`);
//----------------------------------
console.log(`Name: ${name}, Age: ${age}`);
console.log(`Name: ${name2}, Age: ${age2}`);
console.log(`Name: ${person.name}, Age: ${person.age}`);
//----------------------------------
console.log(message());
console.log(text());
//----------------------------------
async function run() {
const module = await import("./math.js");
let result = module.add(2, 3);
console.log(`Dynamically imported add(2, 3): ${result}`);
}
run();