puts("The area of a circle of radius 4 is " + circle\.area(4));
.fi
.RE
@ -416,7 +417,7 @@ exports\.circumference = function (r) {
};
.fi
.RE
The module circle\.js has exported the functions area() and circumference()\. To export an object, add to the special exports object\. (Alternatively, one can use this instead of exports\.) Variables local to the module will be private\. In this example the variable PI is private to circle\.js\.
The module circle\.js has exported the functions area() and circumference()\. To export an object, add to the special exports object\. (Alternatively, one can use this instead of exports\.) Variables local to the module will be private\. In this example the variable PI is private to circle\.js\. The function puts() comes from the module "/utils\.js"\. Because include("/utils\.js") was called, puts() is in the global namespace\.
.sp
The module path is relative to the file calling require()\. That is, circle\.js must be in the same directory as foo\.js for require() to find it\.
.sp
@ -426,6 +427,7 @@ Like require() the function include() also loads a module\. Instead of returning
.RS4
.nf
include("circle\.js");
include("/utils\.js");
puts("The area of a cirlce of radius 4 is " + area(4));