UNPKG

hd-utils

Version:

A handy utils for modern JS developers

11 lines (10 loc) 459 B
/** * @description If the type of the value is a object, return true, otherwise return false. You can pass a function to check for a specific key inside the object * @example isObject({}) //true * @example isObject({}, (obj) => !!obj.name) //false */ const isObject = (val, predicate) => { const isJSObj = !!val && !Array.isArray(val) && typeof val === 'object'; return predicate ? predicate(val) && isJSObj : isJSObj; }; export default isObject;