Skip to content

Instantly share code, notes, and snippets.

@alivelee
Created May 16, 2021 10:50
Show Gist options
  • Save alivelee/405e5b1a4d486fd9125af7f78ae4e826 to your computer and use it in GitHub Desktop.
Save alivelee/405e5b1a4d486fd9125af7f78ae4e826 to your computer and use it in GitHub Desktop.
判断传入的value是否为一个对象。
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