Skip to content

Instantly share code, notes, and snippets.

@Juknum
Last active November 16, 2021 00:00
Show Gist options
  • Save Juknum/6750c0ec3a4249359b5be0641185f917 to your computer and use it in GitHub Desktop.
Save Juknum/6750c0ec3a4249359b5be0641185f917 to your computer and use it in GitHub Desktop.
Object.isObject(object) : Test if a JS Object is an Object
Object.defineProperty(Object.prototype, 'isObject', {
/**
* @param {*} item to be tested
* @returns {Boolean} true if the item is an JS Object
*/
value: (item) => { return (item && typeof item === 'object' && !Array.isArray(item)) }
})
/**
* Examples:
* Object.isObject({}) -> true
* Object.isObject(null) -> false
* Object.isObject('string') -> false
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment