如何从数组中删除特定项目?

我有一个数字数组,我正在用该.push()方法向其中添加元素。有没有一种简单的方法可以从数组中删除特定元素?
我正在寻找类似的东西:array.remove(number);

splice就搞定了


const array = [2, 5, 9];

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

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

js中数组没有remove方法 只有splice方法。

推荐你看下下面的文章 ,几种删除方式总结的还是比较全的

https://www.jb51.net/article/134312.htm