首页 > Web开发 > 详细

js笔记 ---- ECMAscript中原始类型与引用类型 注意的地方

时间:2017-03-06 22:17:07      阅读:154      评论:0      收藏:0      [点我收藏+]

5种原始类型(primitive type ) :number string boolean undefined null   存储在栈中

其中:除开 string类型,其他4中类型的大小都是不变的。

  使用 typeof 的返回值

  undefined   对应Undefined的数据类型

  number   Number

  string          String 

  boolean        Boollean

  object        引用类型或者是null类型

 当判断一个变量是否是什么具体对象值的时候,使用typeof 是无法具体确认的,因为  typeof null  = ‘object ‘, 其他类型无法具体判断

而且  : alert(null == undefined) 返回为true; 这是因为 undefined 实际上是从null上面派生下来的。

 

使用instanceof 运算符可以准确判断是什么引用类型的对象。

 

  

 

js笔记 ---- ECMAscript中原始类型与引用类型 注意的地方

原文:http://www.cnblogs.com/bingo-os/p/6512168.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!