array.filter in js

JavaScript
var numbers = [1, 3, 6, 8, 11];

var lucky = numbers.filter(function(number) {
  return number > 7;
});

// [ 8, 11 ]const words = ['spray', 'limit', 'elite', 'exuberant', 'destruction', 'present'];
const result = words.filter(word => word.length > 6);
console.log(result);var words = ['spray', 'limit', 'elite', 'exuberant', 'destruction', 'present'];

const result = words.filter(word => word.length > 6);

console.log(result);var newArray = array.filter(function(item) {
  return condition;
}); var ages = [32, 33, 16, 40];

function checkAdult(age) {
  return age >= 18;
}

 
function myFunction() {
  document.getElementById("demo").innerHTML = ages.filter(checkAdult);
} var numbers = [1, 3, 6, 8, 11];

var lucky = numbers.filter(function(number) {
  return number > 7;
});
Source

Also in JavaScript: