📌  相关文章
📜  如何在 JavaScript 代码示例中的特定索引处将项目插入到数组中

📅  最后修改于: 2022-03-11 15:03:49.777000             🧑  作者: Mango

代码示例1
var arr = [];
arr[0] = "Apple";
arr[1] = "Grape";
arr[2] = "Pear";
arr[3] = "Peach";
arr[4] = "Grapefruit";

console.log(arr.join()); // Apple,Grape,Pear,Peach,Grapefruit
arr.splice(2, 0, "Orange");
console.log(arr.join()); // Apple,Grape,Orange,Pear,Peach,Grapefruit