filter value in array javascript code example
Example 1: .filter js
const words = ['spray', 'limit', 'elite', 'exuberant', 'destruction', 'present'];
const result = words.filter(word => word.length > 6);
console.log(result);
Example 2: filter in js
const filterThisArray = ["a","b","c","d","e"]
console.log(filterThisArray)
const filteredThatArray = filterThisArray.filter((item) => item!=="e")
console.log(filteredThatArray)
Example 3: array.filter in javascript
const array = [2, 3, 4]
if (event.target.checked) {
newValue.push(option);
} else {
newValue = newValue.filter(item => item.id != option.id);
}
const words = ['spray', 'limit', 'elite', 'exuberant', 'destruction', 'present'];
const result = words.filter(word => word.length > 6);