exports module study
This commit is contained in:
7
nodejs/main.js
Normal file
7
nodejs/main.js
Normal file
@@ -0,0 +1,7 @@
|
||||
let m = require('./math-tools');
|
||||
|
||||
console.log(m.PI);
|
||||
console.log(m.add(1,2));
|
||||
console.log(m.subtract(1,2));
|
||||
console.log(m.multiply(1,2));
|
||||
console.log(m.divide(1,2));
|
||||
9
nodejs/math-tools.js
Normal file
9
nodejs/math-tools.js
Normal file
@@ -0,0 +1,9 @@
|
||||
let calculator = {
|
||||
PI : 3.14,
|
||||
add : (a, b) => a + b,
|
||||
subtract : (a, b) => a - b,
|
||||
multiply : (a, b) => a * b,
|
||||
divide : (a, b) => a / b
|
||||
}
|
||||
|
||||
module.exports = calculator;
|
||||
1
nodejs/test.js
Normal file
1
nodejs/test.js
Normal file
@@ -0,0 +1 @@
|
||||
console.log('Hello Node.js')
|
||||
Reference in New Issue
Block a user