#数据类型
最常见的判断方法:typeof
1 | // 可以区分基本类型和undefined |
判断已知对象类型的方法: instanceof
- null的typeof为object,function和undefined可以使用typeof
1 | # 可以区分object和array分别是哪个构造函数的实例 |
prototype
1 | alert(Object.prototype.toString.call(‘123’) === ‘[object String]’) -------> true; |
#数据类型
1 | // 可以区分基本类型和undefined |
1 | # 可以区分object和array分别是哪个构造函数的实例 |
1 | alert(Object.prototype.toString.call(‘123’) === ‘[object String]’) -------> true; |