Sun Dial Menu
Array.Prototype.filter()
Menu Array.Prototype.filter()
 

Array.Prototype.filter()

How I saw this used - in the JSON page search example.

var filteredList = books.filter(function(book){ .......

What MDN say:

The filter() method creates a new array with all elements that pass the test implemented by the provided function.

An Example:

<script>
function(a) {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"] }
</script>

The example also uses the "short-form" syntax for the a function.

Top

Links

Site design by Tempusfugit Web Design -