基本类型值不是变量,基本包装类型的值是一个变量varnum1=123;varnum2=newNumber(123);typeofnum1;//'number'typeofnum2;//'object'Object.prototype.toString.call(num1);"[objectNumber]"Object.prototype.toString.call(num2);"[objectNumber]"vararr=newArray();Object.prototype.toString.call(arr);"[objectArray]"用Object.prototype.toString.call()方法可以去准确地判断一个非自定义的数据类型,但是这里num1和num2应该是不相同的两种类型为什么返回的是一样的结果,还有这个Number具体是什么意思呢,是基本数据类型中的Number类型呢还是引用类型中的Number类型呢?
2 回答

拉丁的传说
TA贡献1789条经验 获得超8个赞
看规范19.1.3.6WhenthetoStringmethodiscalled,thefollowingstepsaretaken:Ifthethisvalueisundefined,return"[objectUndefined]".Ifthethisvalueisnull,return"[objectNull]".LetObeToObject(thisvalue)....会自动包装
添加回答
举报
0/150
提交
取消