Skip to content

Instantly share code, notes, and snippets.

@neftaly
Last active August 29, 2015 14:16
Show Gist options
  • Select an option

  • Save neftaly/223edfdb0f7bc0ff05e5 to your computer and use it in GitHub Desktop.

Select an option

Save neftaly/223edfdb0f7bc0ff05e5 to your computer and use it in GitHub Desktop.
Functional object creation
var keys = ["foo", "bar", "baz"];
object = keys.reduce(function (partialObject, key) {
partialObject[key] = 1;
return partialObject;
}, {});
//=> { foo: 1, bar: 1, baz: 1 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment