Skip to content

Instantly share code, notes, and snippets.

@jhuttner
Created December 7, 2011 19:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jhuttner/1444210 to your computer and use it in GitHub Desktop.
Save jhuttner/1444210 to your computer and use it in GitHub Desktop.
if (!items_by_name[name]) {
items_by_name[name] = [];
}
items_by_name[name].push(item);
// could we do something like this?
items_by_name[name].smart_push(item, [])
@travisj
Copy link

travisj commented Dec 7, 2011

items_by_name ? items_by_name.push(item) : items_by_name = [item];

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