Skip to content

Instantly share code, notes, and snippets.

@bethsecor
Forked from rrgayhart/require.markdown
Last active March 31, 2016 03:44
Show Gist options
  • Save bethsecor/f0bcd7efb541d9859bcedb8df599553e to your computer and use it in GitHub Desktop.
Save bethsecor/f0bcd7efb541d9859bcedb8df599553e 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 piece of your javascript code that could contain a class, or functions, or variables that are common or related to each other and warrant their own file.
  • The code examples from the second blog post look very different from the first. Why?

    • The first blog post uses what we've been shown before, module.exports whereas the second post uses a define function. The define function comes from a different javascript module loader RequireJS, and module.exports comes from CommonJS.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment