Java Reference
In-Depth Information
var name = "Module A";
console.log("Hello from " + name);
}());
(function() {
// Module B
var name = "Module B";
console.log("Hello from " + name);
}());
<< "Hello from Module A"
"Hello from Module B
Notice that both modules include a variable called
name
, but the modules don't interfere
with each other. This is a useful approach for separating parts of a program into discrete
modules, especially for testing purposes.