Skip to content

Instantly share code, notes, and snippets.

@matt-stj
Forked from rrgayhart/require.markdown
Last active February 9, 2016 07:14
Show Gist options
  • Save matt-stj/011336982aaed50e9d14 to your computer and use it in GitHub Desktop.
Save matt-stj/011336982aaed50e9d14 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 way to encapsulate/organize related code. Modules require that you expilcitly require or export the code contained within if you wish to use the functions or variables elsewhere in your program.

  • The code examples from the second blog post look very different from the first. Why?
    In the second example, they are using require.js to export modules. Instead of haing to call require() or export() , they can use require.js's syntax of define to acheive the same thing.

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