Skip to content

Instantly share code, notes, and snippets.

@alirezaandersen
Forked from rrgayhart/require-1602.markdown
Last active July 11, 2016 04:37
Show Gist options
  • Save alirezaandersen/063d8315da1804238bb2b478bb08582d to your computer and use it in GitHub Desktop.
Save alirezaandersen/063d8315da1804238bb2b478bb08582d to your computer and use it in GitHub Desktop.
The Concept of Require

When you start working with WebPack for GameTime, you'll notice that you can't just define a variable in one file and find it in another as easily as you can in Rails.

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?

  • A Module is a the fundamental Node building block which maps directly to a file. Almost like Ruby in which you can take a class or method and import/export it to another file allowing you to use the previous files functions in the new one.

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

  • The second post is using require.js which is a library making life easier to use, in order to associate things inside the module with variables in another file. The first post seemed to be more hands thus allowing the user to be more explicit for what they want.

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