Created
September 25, 2024 23:37
-
-
Save OrderAndCh4oS/2e517952a3ccdc3bfa00fb2eb505767b to your computer and use it in GitHub Desktop.
isObject
This file contains hidden or 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
const isObject = (obj?: unknown): obj is object => | |
Boolean(obj) && (obj?.constructor === Object); | |
console.log(isObject()); // false | |
console.log(isObject(null)); // false | |
console.log(isObject(true)); // false | |
console.log(isObject(1)); // false | |
console.log(isObject('str')); // false | |
console.log(isObject([])); // false | |
console.log(isObject(new Date)); // false | |
console.log(isObject(() => { })); // false | |
console.log(isObject(function() { })); // false | |
console.log(isObject({})); // true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment