日期:2014-05-16  浏览次数:20299 次

JavaScript中六种对象类型
虽然常见但是好记性不如烂笔头,记录下这些:

typeof 123456       'number'

typeof '123456'     'string'

typeof true/false   'boolean'

typeof function(){} 'function'

typeof null         'object'

typeof undefined    'undefined'

typeof NaN // 'number'
typeof new RegExp // 'object'
typeof RegExp // 'function
typeof isNaN  // 'function


Boolean('true') //true
Boolean('false') //true
null == undefined    true

null === undefined   false

NaN === NaN          false

NaN == NaN           false

需要注意的是typeof(null)返回是'object'类型,NaN === NaN 和 NaN == NaN返回false
JavaScript固有特性:任何对象竟不相等(==)也不全等(===),如:[] == [], {} == {}
,[] === [], {} === {} 都返回false.同时函数也是对象。


参考:
http://blog.csdn.net/aimingoo/archive/2010/12/25/6097378.aspx