Add property to each object in the array

后端 未结 3 1281
执念已碎
执念已碎 2021-01-25 04:04

I\'m trying to add a property to each object in the array:

var capitals = [{
    country: \"What\'s the capital of Ecuador?\",
    choices: [\"Quito\", \"Caracas         


        
3条回答
  •  醉话见心
    2021-01-25 04:47

    If you do not have to support legacy browsers, then you could use Array.prototype.map

提交回复
热议问题