Skip to content

Instantly share code, notes, and snippets.

@hughfdjackson
Last active December 18, 2015 12:09
Show Gist options
  • Save hughfdjackson/5780695 to your computer and use it in GitHub Desktop.
Save hughfdjackson/5780695 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