js基础 Numberd对象,Boolean对象

一、Number对象
Number.MAX_VALUE 获取计算机能存储的最大值
Number.MIN_VALUE 存储的最小值
toFixed(n) 保留小数点后n位 

二、Boolean对象
new Boolean() 本质上是把数据转换为布尔型的值
另一种转换为布尔型 !!value -->true/false

//Boolean对象
//哪些情况false
//undefined,null,0,false,NaN,''
var b1 = new Boolean(undefined);  //[Boolean: false] object
var b2 = new Boolean(null);  //[Boolean: false] object
var b3 = new Boolean(0);  //[Boolean: false] object
var b4 = new Boolean(false);  //[Boolean: false] object
var b5 = new Boolean(NaN);  //[Boolean: false] object
var b6 = new Boolean('');  //[Boolean: false] object
var b7 = new Boolean();  //[Boolean: false] object
var b8 = new Boolean({});  //[Boolean: true] object
var b9 = new Boolean([]);  //[Boolean: true] object
var b10 = new Boolean(1);  //[Boolean: true] object
//console.log(b10);
//console.log(typeof b10);  

//转换任何的数据为布尔型!!
console.log(!!1);  //false-->true
console.log(!![1,2,3]);  //true
console.log(!!NaN);   //false


上一篇: js基础 Date对象
下一篇: js基础 错误处理
作者邮箱: 203328517@qq.com