Super simple Array.prototype.map()
job
names.map(name => ({ name }))
That is... map each entry (name
) to an object with key "name" and value name
.
var names = [
"Bob",
"Michael",
"Lanny"
];
console.info(names.map(name => ({ name })))
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…