Skip to content

hasValue

Subhajit Sahu edited this page May 3, 2023 · 14 revisions

Examine if array has a value.

Similar: randomValue, values, hasValue, searchValue.
Similar: hasValue, hasPrefix, hasInfix, hasSuffix, hasSubsequence, hasPermutation, hasPath.


function hasValue(x, v, fc, fm)
// x:  an array
// v:  search value
// fc: compare function (a, b)
// fm: map function (v, i, x)
const xarray = require('extra-array');

var x = [1, 2, -3];
xarray.hasValue(x, 3);
// → false

xarray.hasValue(x, 3, (a, b) => Math.abs(a) - Math.abs(b));
// → true

xarray.hasValue(x, 3, null, v => Math.abs(v));
// → true


References

Clone this wiki locally