array-turn-object
v1.0.1
Published
array-to-object
Downloads
3
Readme
// 数组转为对象
var array2Object = require('./lib/array2Object.js');
var arr = [
{
id: 1,
name: '张三',
age: 20
},{
id: 2,
name: '王二',
age: 16
},{
id: 3,
name: '李四',
age: 24
}
]
var object = array2Object.arr2Obj(arr, 'id', 'name')
// output
object { '1': '张三', '2': '王二', '3': '李四' }