JavaScript: Array.prototype.filter

By Xah Lee. Date: . Last updated: .
arrayX.filter(f)
Return a new array, with elements that f return true.
The function f is passed 3 args: • current_elementcurrent_indexarrayX.
arrayX.filter(f, thisArg)
Use thisArg for this Binding of f. If it is not given, undefined is used.
const isEven = (x => ( x % 2 === 0 ) )

const arr = [7,3,4,2];

console.log( arr.filter ( isEven ) ); // [ 4, 2 ]

// original not changed
console.log( arr ); // [ 7, 3, 4, 2 ]
JS in Depth
XAH  BUY NOW

JS in Depth

JS Obj Ref

DOM


JS Obj Ref

Array

prototype