Last active
November 16, 2021 00:00
-
-
Save Juknum/6750c0ec3a4249359b5be0641185f917 to your computer and use it in GitHub Desktop.
Object.isObject(object) : Test if a JS Object is an Object
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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