Read Node.js, Require and Exports and Organize Your Code with RequireJS
- In the context of Node, what is a
module
?
"Modules are small chunks of your application that serve a specific purpose"... In the context of Node, a module is a set of objects with a given purpose in the program that are stored together and accessible within a one file. These act similarly to a module or class in Ruby in that they serve to group data and functions which are callable from other files through importing and exporting.
- The code examples from the second blog post look very different from the first. Why?
The code examples in the second article look different than the first because the second article is describing the use of RequireJS to organize code and create module dependencies which uses define() and only calls require() in the main file.