Skip to content

filter$

Subhajit Sahu edited this page May 19, 2020 · 34 revisions

Keeps values which pass a test. 🏃 📼 📦 🌔 📒

Alternatives: filter, filter$.
Similar: map, filter, reduce.

array.filter$(x, fn, [ths]);
// x:   an array (updated)
// fn:  test function (v, i, x)
// ths: this argument
// --> x
const array = require('extra-array');

var x = [1, 2, 3, 4, 5];
array.filter(x, v => v % 2 === 1);
// [ 1, 3, 5 ]

x;
// [ 1, 3, 5 ]

var x = [1, 2, 3, 4, 5];
array.filter(x, v => v % 2 === 0);
// [ 2, 4 ]

references

Clone this wiki locally