向数组中插入数据,先进先出,先进后出
var array = [“one”, “two”, “four”];
array.splice(2, 0, “three”); //指定要插入数据的下标
console.log(array);
输出结果是: [“one”, “two”, “three”, “four”] 。
向数组中插入数据,先进先出,先进后出
var array = [“one”, “two”, “four”];
array.splice(2, 0, “three”); //指定要插入数据的下标
console.log(array);
输出结果是: [“one”, “two”, “three”, “four”] 。