
array.filter() – Returns a **new array** containing only the elements for which the callback returns a truthy value.
๐ Syntax
newArray = array.filter((element, index, array) => {
return /* condition */;
}, thisArg);
๐งช Example
const nums = [5, 12, 8];
const big = nums.filter(n => n > 10);
console.log(big); // [12]
Comments
Post a Comment