js filter to delete all elements in the array that meet the conditions

filter is used to filter the array.
It creates a new array whose elements are checked by checking all elements in the specified array that meet the criteria.

Note: filter() will not detect empty arrays and will not change the original array

let nums = [1, 2, 3, 4, 3, 5, 6];
let res = nums.filter(item=> item !== 3);
console.log(res); //  [1, 2, 4, 5, 6]

Guess you like

Origin blog.csdn.net/qq_41954585/article/details/130634332