Skip to content

Instantly share code, notes, and snippets.

@martensonbj
Forked from rrgayhart/require.markdown
Last active April 4, 2016 02:44
Show Gist options
  • Save martensonbj/37e7e41c4e1fddefbd580ae63daead89 to your computer and use it in GitHub Desktop.
Save martensonbj/37e7e41c4e1fddefbd580ae63daead89 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 containing element for related pieces of code. Often a separate .js file, modules are used to organize and pass along information to other files using the require() syntax.
  • The code examples from the second blog post look very different from the first. Why?
    • The second blog post uses a define method instead of require to specify the modules needed to perform a function using RequireJS. Not entirely clear on when or why to use one over the other.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment