js array .filter

JavaScript
var words = ['spray', 'limit', 'elite', 'exuberant', 'destruction', 'present'];

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

console.log(result);var numbers = [1, 3, 6, 8, 11];

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

// [ 8, 11 ]var newArray = array.filter(function(item) {
  return condition;
});//Eg 1 - If item is unchecked, remove it from array

const array = [2, 3, 4]

if (event.target.checked) {
      newValue.push(option);
    } else {
      newValue = newValue.filter(item => item.id != option.id);
    }

//If false, it will remove the element. 2 is not equal to 2.

//Eg 2 - To return an array with length > 6

const words = ['spray', 'limit', 'elite', 'exuberant', 'destruction', 'present'];
const result = words.filter(word => word.length > 6);
// The filter() method creates a new array with all elements 
// that pass the test implemented

const words = ['spray', 'limit', 'elite', 'exuberant', 'destruction', 'present'];

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

console.log(result);
// expected output: Array ["exuberant", "destruction", "present"]
const filterArray=(a,b)=>{return a.filter((e)=>{return e!=b})}

let array = ["a","b","","d","","f"];

console.log(filterArray(array,""));//>> ["a","b","d","f"]
Source

Also in JavaScript: