Skip to content

Instantly share code, notes, and snippets.

@amcrawford
Forked from rrgayhart/require.markdown
Last active February 14, 2016 03:27
Show Gist options
  • Save amcrawford/796c0b3d218e24e5dda4 to your computer and use it in GitHub Desktop.
Save amcrawford/796c0b3d218e24e5dda4 to your computer and use it in GitHub Desktop.
The Concept of Require

Read Node.js, Require and Exports and Organize Your Code with RequireJS

Fork this gist and answer the following questions:

  • 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment