Skip to content

Instantly share code, notes, and snippets.

@flipjs
Created July 28, 2014 23:20
Show Gist options
  • Save flipjs/5e41b67f02dab3d869ee to your computer and use it in GitHub Desktop.
Save flipjs/5e41b67f02dab3d869ee to your computer and use it in GitHub Desktop.
POJO
var pojo = function () {
var members = arguments
, ctr = 0
return function () {
var obj = {}
, i = 0
, len = members.length
ctr += 1
for (; i < len; i += 1) {
obj[members[i]] = arguments[i]
}
return obj
}
}
var contactObj = pojo('firstName', 'lastName', 'telephone', 'email')
var contact = contactObj("Felipe", "Apostol", "+(632) 8332244", "flip@flipjs.io")
console.log(contact)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment