📜  how-can-i-remove-a-specific-item-from-an-array - Javascript 代码示例

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

代码示例1
const array = [2, 5, 9];

console.log(array);

const index = array.indexOf(5);
if (index > -1) {
  array.splice(index, 1);
}

// array = [2, 9]
console.log(array); 
 Run code snippet