has()

Returns true if the key is defined in the provided collection.

has(collection: object, key: unknown): boolean

Discussion

A functional alternative to collection.has(key) which will also work with plain Objects and Arrays as an alternative for collection.hasOwnProperty(key).

const { has } = require('immutable')
has([ 'dog', 'frog', 'cat' ], 2) // true
has([ 'dog', 'frog', 'cat' ], 5) // false
has({ x: 123, y: 456 }, 'x') // true
has({ x: 123, y: 456 }, 'z') // falserun it
This documentation is generated from immutable.d.ts. Pull requests and Issues welcome.

© 2014–present, Lee Byron and other contributors
Licensed under the 3-clause BSD License.
https://immutable-js.com/docs/v4.0.0/has()/