普通方式创建 | typeof | instanceof | new方式创建 | typeof | instanceof | |
Object | var o={}; | object | Object | var o=new Object(); | object | Object |
Array | var a=[]; | object | Array | var a=new Array(); | object | Array |
Function | var f = function(){}; | function | Function | var f = new Function(); | function | Function |
String | var s="hello,world"; | string | var s=new String("hello,world"); | object | String | |
Number | var n =5; | number | var n =new Number(5); | object | Number | |
Boolean | var b=true; | boolean | var b=new Boolean(true); | object | Boolean | |
null | var nl= null; | object | ||||
undefined | var un=undefined; | undefined | ||||
*1."typeof operator returns a string indicating the type of the unevaluated operand." ---from MDC | ||||||
*2."obj instanceof ConstructorFunction works by checking if ConstructorFunction.prototype is in the prototype chain of obj. "----from MDC |
typeof and instanceof
最新推荐文章于 2024-03-18 08:00:00 发布