Created
May 16, 2021 10:50
-
-
Save alivelee/405e5b1a4d486fd9125af7f78ae4e826 to your computer and use it in GitHub Desktop.
判断传入的value是否为一个对象。
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
function isObject(obj) { | |
return obj === Object(obj); | |
} | |
isObject([1, 2, 3, 4]); // true | |
isObject([]); // true | |
isObject(['Hello!']); // true | |
isObject({ a: 1 }); // true | |
isObject({}); // true | |
isObject(true); // false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment