Skip to content

Instantly share code, notes, and snippets.

@theonlyrao
Last active July 6, 2016 00:05
Show Gist options
  • Save theonlyrao/29ea7f78adc7c92a385f83d8a9e75435 to your computer and use it in GitHub Desktop.
Save theonlyrao/29ea7f78adc7c92a385f83d8a9e75435 to your computer and use it in GitHub Desktop.
Ashwin Rao - The Concept of Require

Questions:

  • In the context of Node, what is a module?

A module is a fundamental Node building block that maps to a file. To expose the objects or methods contained in the module, i.e. another file, requires using module.exports in the module for anything that should be exposed, and to require the exported things in the file that wants to use them.

  • The code examples from the second blog post look very different from the first. Why?

I really hope it's because the second blog post is using RequireJS and all that syntax is sugar created by RequireJS in order to associate things inside the module with variables in other files.

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