javascript string filter code example
Example 1: string filter javascript
var PATTERN = /bedroom/,
filtered = myArray.filter(function (str) { return PATTERN.test(str); });
Example 2: array filter
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"]
Example 3: js filter items by index
let newArray = arr.filter(callback(element[, index, [array]])[, thisArg])