gpt4 book ai didi

Javascript 数组集合追加

转载 作者:行者123 更新时间:2023-12-01 02:17:28 26 4
gpt4 key购买 nike

嗨,我得到了这个数组:

  var locations = [
['Bondi Beach', -33.890542, 151.274856, 4],
['Coogee Beach', -33.923036, 151.259052, 5],
['Cronulla Beach', -34.028249, 151.157507, 3],
['Manly Beach', -33.80010128657071, 151.28747820854187, 2],
['Maroubra Beach', -33.950198, 151.259302, 1]
];

我想像示例一样附加到它:

var locations = [
['Bondi Beach', -33.890542, 151.274856, 4],
['Coogee Beach', -33.923036, 151.259052, 5],
['Cronulla Beach', -34.028249, 151.157507, 3],
['Manly Beach', -33.80010128657071, 151.28747820854187, 2],
['Maroubra Beach', -33.950198, 151.259302, 1],
['New item', -22.950198, 141.259302, 6]
];

我不知道该怎么做,搜索“将项目添加到数组中的数组”似乎不太有效。

最佳答案

var locations = [
['Bondi Beach', -33.890542, 151.274856, 4],
['Coogee Beach', -33.923036, 151.259052, 5],
['Cronulla Beach', -34.028249, 151.157507, 3],
['Manly Beach', -33.80010128657071, 151.28747820854187, 2],
['Maroubra Beach', -33.950198, 151.259302, 1]
];

var newLocation = ['New item', -22.950198, 141.259302, 6];

locations.push(newLocation);

关于Javascript 数组集合追加,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49406246/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com