使用filter数组过滤另一个数组


描述:

从一个大数组中过滤掉一个小数组,获得大数组中的其他数据

const words = ['spray', 'limit', 'elite', 'exuberant', 'destruction', 'present'];
const w = ['spray', 'limit', 'elite', 'exuberant',];
const result = words.filter(word => w.indexOf(word)==-1);
console.log(result);

// 输出: Array ["destruction", "present"]