What are the ways to determine what type a value is?
typeof 运算符
instanceof 运算符
Object.prototype.toString 方法
const a=true;
typeof(a);
a instanceof Number;
Object.prototype.toString.call(a);
Note:
typeof() will make an error when judging the array, and it will be judged as an object.
When instanceof judges arrays and functions, it judges that Object is also true.
Object.prototype.toString is accurate.