js splice vs slice
https://*.com/questions/37601282/javascript-array-splice-vs-slice
https://www.w3schools.com/jsref/jsref_slice_string.asp
let dataGET = [
{
index: 0,
keyword: "a",
value: "1",
description: "a=1",
operate: ["edit", "save", "cancel"],
isEdit: false,
},
{
index: 1,
keyword: "b",
value: "2",
description: "b=1",
operate: ["edit", "save", "cancel"],
isEdit: false,
},
{
index: 2,
keyword: "c",
value: "3",
description: "c=1",
operate: ["edit", "save", "cancel"],
isEdit: false,
},
];
// let arr = dataGET.slice(1, 1);
// console.log(arr);
//splice
var array=[1,2,3,4,5];
console.log(array.splice(2, 1));
//slice
var array2=[1,2,3,4,5]
console.log(array2.slice(2, 1));
console.log("----after-----");
console.log(array);
console.log(array2);
splice & delete Array item by index
index = 2
//splice & will modify the origin array
const arr1 = [1,2,3,4,5];
//slice & won't modify the origin array
const arr2 = [1,2,3,4,5]
console.log("----before-----");
console.log(arr1.splice(2, 1));
console.log(arr2.slice(2, 1));
console.log("----after-----");
console.log(arr1);
console.log(arr2);
©xgqfrms 2012-2020
www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!