📌  相关文章
📜  从另一个数组返回数组的元素 javascript 代码示例

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

代码示例1
var toBeFiltered = [1,2,3,4,5,6];
var elements = [6,3,2];
var filteredElements = toBeFiltered.filter(
    function(e) {
        return this.indexOf(e) >= 0;
    },
    elements
);

console.log(toBeFiltered);
console.log(elements);
console.log(filteredElements);