Infinity NaN undefined和null

Infinity属性用于存放表示正无穷大的数值.
负无穷大是表示负无穷大一个数字值.
该属性为Global对象的一个只读属性, 所有主流浏览器均支持该属性.
Infinity属性的值为Number类型, 其值一般输出显示为Infinity.

该属性与Number.POSITIVE_INFINITY属性完全相同.

在Javascript中, 超出1.7976931348623157E+10308的数值即为Infinity, 小于-1.7976931348623157E+103088的数值为无穷小. 
var x=1.7976931348623157E+10308;
document.write(x + "<br>");//Infinity

var y=-1.7976931348623157E+10308;
document.write(y);//-Infinity
 
console.log(Infinity);//Infinity:无穷大
console.log(typeof Infinity);//number
 
NaN是一个特殊值, 用于表示算术表达式返回了非数字的值.
NaN和Number.NaN属性完全相同.
NaN是Global对象一个只读属性,所有浏览器都兼容.
NaN的值不与任何值相等,包括其本身.若要测试某值是否等效于NaN,使用isNaN()函数.
document.writeln( NaN );//NaN
document.writeln( typeof NaN );//number

//NaN不与自身相等
document.writeln( NaN === NaN );//false
//也不与自身的值相等
document.writeln( NaN == NaN );//false

//使用isNaN()函数判断一个值是否等效于NaN
document.writeln( isNaN("张三") ); //true
 
undefined属性是已声明一个变量还没有进行初始化,则其值是undefined.undefined是缺少值.

(1)变量被声明了,但没有赋值时,就等于undefined。

(2) 调用函数时,应该提供的参数没有提供,该参数等于undefined。

(3)对象没有赋值的属性,该属性的值为undefined。

(4)函数没有返回值时,默认返回undefined。

document.writeln( undefined ); // undefined
document.writeln( typeof undefined ); // undefined
null表示无的对象.即该处不应该有值.

(1) 作为函数的参数,表示该函数的参数不是对象。

(2) 作为对象原型链的终点。

Object.getPrototypeOf(Object.prototype)
//null
posted @ 2016-10-08 16:33  SkyTeam_LBM  阅读(527)  评论(0编辑  收藏  举报