Function: objHasKeys()
objHasKeys(
input,keys,requireValue):boolean
Defined in: packages/core/src/obj/objHasKeys.ts:29
Checks if all the supplied keys exist in an object
Parameters
input
object | unknown[]
keys
PropertyKey[] = []
requireValue
boolean = false
(optional) whether each property should have some value.
Returns
boolean
Example
Check if object contains specified properties
javascript
import { objHasKeys } from '@superutils/core'
const obj = { a: 1, b: null, c: 0 }
console.log(objHasKeys(obj, ['a', 'b']))
// true
console.log(
objHasKeys(
obj,
['a', 'b'],
true // check if all the respective values of the provided keys are not "empty". Uses `ìsEmpty()`.
)
)
// false