array.filter return code example
Example 1: filter javascript array
var words = ['spray', 'limit', 'elite', 'exuberant', 'destruction', 'present'];
const result = words.filter(word => word.length > 6);
console.log(result);
Example 2: javascript array filter
run.addEventListener("click", function () {
let array = [];
people.forEach((elem) => {
if (elem.age > 18) {
array.push(elem);
} else {
("");
}
});
console.log(array);
});
Example 3: js filter items by index
let newArray = arr.filter(callback(element[, index, [array]])[, thisArg])