标签:define ceo strong dep 数据类型 环境 this dex 返回
判断js中的数据类型有一下几种方法:typeof、instanceof、 constructor、 prototype、 $.type()/jquery.type(),接下来主要比较一下这几种方法的异同。
例子:
var a = "iamstring.";var b = 222;var c= [1,2,3];var d = new Date();var e = function(){alert(111);};var f = function(){this.name="22";};
alert(typeof a) ------------> string
alert(typeof b) ------------> number
alert(typeof c) ------------> object
alert(typeof d) ------------> object
alert(typeof e) ------------> function
alert(typeof f) ------------> function
typeof可能的返回值| 类型 | 结果 |
|---|---|
| Undefined | "undefined" |
| Null | "object"(见下文) |
| Boolean | "boolean" |
| Number | "number" |
| String | "string" |
| Symbol (ECMAScript 6 新增) | "symbol" |
| 宿主对象(由JS环境提供) | Implementation-dependent |
| 函数对象([[Call]] 在ECMA-262条款中实现了) | "function" |
| 任何其他对象 | "object" |
标签:define ceo strong dep 数据类型 环境 this dex 返回
原文地址:https://www.cnblogs.com/Marinnn/p/9395017.html