2020-05-13 在数组中删除指定元素(Array.splice(index,howMany))

function remove(arr, val) {
    var index = arr.indexOf(val);
    if (index > -1) {
        arr.splice(index, 1);
    }
};

var emp = [
    { "username": 123 },
    { "sdf": 123 }
]

remove(emp,emp[1]);
console.log(emp);//[ { username: 123 } ]

你可能感兴趣的:(2020-05-13 在数组中删除指定元素(Array.splice(index,howMany)))