小编Ale*_*rez的帖子

如何从多个数组创建对象数组

给定以下数组:

var ids = [1,2,3]; //Hundreds of elements here
var names = ["john","doe","foo"]; //Hundreds of elements here
var countries = ["AU","USA,"USA"]; //Hundreds of elements here
Run Code Online (Sandbox Code Playgroud)

生成具有与此类似结构的对象数组的最佳性能方法是什么:

var items = [
    {id:1,name:"john",country:"AU"},
    {id:2,name:"doe",country:"USA"},
    ...
];
Run Code Online (Sandbox Code Playgroud)

javascript arrays ecmascript-6

2
推荐指数
1
解决办法
2983
查看次数

标签 统计

arrays ×1

ecmascript-6 ×1

javascript ×1