Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dankahle/b5c59c7cf7802d8758d7 to your computer and use it in GitHub Desktop.
Save dankahle/b5c59c7cf7802d8758d7 to your computer and use it in GitHub Desktop.
An example of how to share code between the browser and node. You need to "module.exports" the arrays in node, but not in the browser.
var users = [
{id:'dk', name: 'dank', age:50},
{id:'cy', name: 'carl', age:60},
{id:'js', name: 'jim', age:40}
];
if(!window && typeof module != 'undefined'){
module.exports.friends = friends;
module.exports.users = users;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment