@extra-array/has-value
Version:
Checks if array has a value.
61 lines (46 loc) • 2.05 kB
Markdown
Checks if array has a value.
[:package:](https://www.npmjs.com/package/@extra-array/has-value)
[:smiley_cat:](https://github.com/orgs/nodef/packages?repo_name=extra-array)
[:running:](https://npm.runkit.com/@extra-array/has-value)
[:vhs:](https://asciinema.org/a/343744)
[:moon:](https://www.npmjs.com/package/@extra-array/has-value.min)
[:scroll:](https://unpkg.com/@extra-array/has-value/)
[:newspaper:](https://nodef.github.io/extra-array/)
[:blue_book:](https://github.com/nodef/extra-array/wiki/)
> Similar: [value], [values], [hasValue], [searchValue].<br>
> Similar: [hasValue], [hasPrefix], [hasInfix], [hasSuffix], [hasSubsequence], [hasPermutation], [hasPath].
> This is part of package [extra-array].
[extra-array]: https://www.npmjs.com/package/extra-array
<br>
```javascript
array.hasValue(x, v, [fc], [fm]);
// x: an array
// v: value?
// fc: compare function (a, b)
// fm: map function (v, i, x)
```
```javascript
const array = require("extra-array");
var x = [1, 2, -3];
array.hasValue(x, 3);
// false
array.hasValue(x, 3, (a, b) => Math.abs(a) - Math.abs(b));
// true
array.hasValue(x, 3, null, v => Math.abs(v));
// true
```
<br>
<br>
## References
- [Array.prototype.includes: MDN web docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes)
- [array-tools.contains: @75lb](https://www.npmjs.com/package/array-tools)
[value]: https://github.com/nodef/extra-array/wiki/value
[values]: https://github.com/nodef/extra-array/wiki/values
[hasValue]: https://github.com/nodef/extra-array/wiki/hasValue
[searchValue]: https://github.com/nodef/extra-array/wiki/searchValue
[hasPrefix]: https://github.com/nodef/extra-array/wiki/hasPrefix
[hasInfix]: https://github.com/nodef/extra-array/wiki/hasInfix
[hasSuffix]: https://github.com/nodef/extra-array/wiki/hasSuffix
[hasSubsequence]: https://github.com/nodef/extra-array/wiki/hasSubsequence
[hasPermutation]: https://github.com/nodef/extra-array/wiki/hasPermutation
[hasPath]: https://github.com/nodef/extra-array/wiki/hasPath