File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change 66
77Node.js has a simple module loading system. In Node.js, files and modules
88are in one-to-one correspondence (each file is treated as a separate module).
9- As an example, ` foo.js ` loads the module ` circle.js ` in the same directory.
109
11- The contents of ` foo.js ` :
10+ As an example, consider a file named ` foo.js ` :
1211
1312``` js
1413const circle = require (' ./circle.js' );
1514console .log (` The area of a circle of radius 4 is ${ circle .area (4 )} ` );
1615```
1716
18- The contents of ` circle.js ` :
17+ On the first line, ` foo.js ` loads the module ` circle.js ` that is in the same
18+ directory as ` foo.js ` .
19+
20+ Here are the contents of ` circle.js ` :
1921
2022``` js
2123const PI = Math .PI ;
2224
2325exports .area = (r ) => PI * r * r;
2426
2527exports .circumference = (r ) => 2 * PI * r;
26-
2728```
2829
2930The module ` circle.js ` has exported the functions ` area() ` and
You can’t perform that action at this time.
0 commit comments