I've got this object:
var obj = {
name : 'Allen',
last : 'Jones',
age : 24,
city : 'London'
}
and this array : ['name', 'age', 'city']
What is the most efficient way to create an object from that selected fields? Such as below, without to delete the properties of the first one?
obj2 = {name: 'allen', age: 24, city: 'London'}
Array.prototype.reduce()Array#reduce, jsfiddle.net/rayon_1990/qx1mz2dp