JS: Array.prototype.filter

By Xah Lee. Date: . Last updated: .
xArray.filter(f)

Return a new array, with elements that f return true.

f is passed 3 args: currentElement, currentIndex, xArray.

console.log([0, 1, 2, 3, 4, 5].filter((x) => (x % 2 === 0)));
// [ 0, 2, 4 ]
xArray.filter(f, thisArg)

Use thisArg for this-binding of f. Default to undefined.