Skip to content

Instantly share code, notes, and snippets.

@hayesmaker
Forked from hughfdjackson/build.js
Created June 14, 2013 10:20
Show Gist options
  • Save hayesmaker/5780851 to your computer and use it in GitHub Desktop.
Save hayesmaker/5780851 to your computer and use it in GitHub Desktop.
var build = function(){
var args = Array.prototype.slice.call(arguments)
var obj = {}
for ( var i = 0, len = args.length; i < len; i += 2 ) obj[args[i]] = args[i + 1]
return obj
}
var name1 = 'x'
var name2 = 'y'
var object = build(
name1, 1,
name2, 2
)
object // { x: 1, y: 2 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment