We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Examine if array starts with a prefix.
Similar: randomPrefix, prefixes, hasPrefix. Similar: hasValue, hasPrefix, hasInfix, hasSuffix, hasSubsequence, hasPermutation, hasPath.
function hasPrefix(x, y, fc, fm) // x: an array // y: search prefix // fc: compare function (a, b) // fm: map function (v, i, x)
const xarray = require('extra-array'); var x = [1, 2, 3, 4]; xarray.hasPrefix(x, [1, 2]); // → true xarray.hasPrefix(x, [-1, -2]); // → false xarray.hasPrefix(x, [-1, -2], (a, b) => Math.abs(a) - Math.abs(b)); // → true xarray.hasPrefix(x, [-1, -2], null, v => Math.abs(v)); // → true