`
liuqiyu
  • 浏览: 27628 次
  • 性别: Icon_minigender_1
  • 来自: 珠海
社区版块
存档分类
最新评论

JavaScript The Definitive Guide Note Part 2

阅读更多

3.13. Primitive Datatype Wrapper Objects

each of the three key primitive datatypes has wrapper , that cantains the save primitive data value, but it also defines properties and mathods. when you try to access a property or method of the primitive datatypes, JavaScript internally creates a wrapper object for it.

eg. var len = s.length; s remains a string, a new transient String object is created for you to access the length property, and then the trainsient object is discarded.

3.14. Object-to-Primitive Conversion

非null的object转成Boolean时,就被转换成true.

object转成数字的时候,是调用valueOf()方法,如果没有返回一个primitive value,将调用toString()方法把string转成number

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics