js⑥

// 万物皆对象

var num = 123456.789;
 console.log(num.toFixed(2));
 console.log(num.toExponential())
 console.log(num.toPrecision(2));

console.log((1.2345).toFixed(2));

console.log(Math.PI);
 console.log(Math.abs(-10));

console.log(Math.max(12, 20));

console.log(Math.ceil(10.00));
 console.log(Math.floor(10.99));
 console.log(Math.round(10.6));

var num = Math.random();
 console.log(num);

console.log(Math.floor(Math.random() * 21));

var myDate = new Date();
 console.log(myDate);

console.log(Date());
 console.log(myDate.getDate());
 console.log(myDate.getMonth());
 console.log(myDate.getFullYear());
 console.log(myDate.getDay());
 console.log(myDate.getTime());
 console.log(myDate.getTimezoneOffset());

myDate.setHours(10);

console.log(myDate.getUTCHours());

console.log(myDate.toString());
console.log(myDate.toLocaleString());
console.log(myDate.toTimeString());
console.log(myDate.toLocaleTimeString());
##检测类名

引用类型:把引用类型的数据赋值给变量的时候,并不会把数据本身赋值给变量,而是把这个数据的引用赋值给变量

var arr = [1,2,3];
var arr2 = arr;
arr[1] = 10;
console.log(arr2);

上一篇:C语言程序设计第十次作业


下一篇:hdu 2489 最小生成树状态压缩枚举