findIndex --裁剪
bash
let index = this.options.findIndex(item=> item.value == val)
this.comList.push(this.options[index])
this.options.splice(index, 1);
findIndex 返回数组下标
filter--过滤
bash
var newList = [...this.list] //...深拷贝,JSON.parse(JSON.Stringify),split
newList = newList.filter(item=>item.id !== id) //删除过滤
filter不改变原数组,所以要重新赋值
indexOf,includes--可判断数组,也可以判断字符串,判断有无,下标
bash
let languages = ["JavaScript", "C", "Java","C++", "Python", "Lua"];
let check = languages.includes("Java"); //有java返回true,没有返回false
languages.indexOf("Java") //有就返回下标2,没有返回-1