new Date()
- new Date()获取到的是系统时间,以服务器时间为准。
类型判断主要方法
var data = “”;//获取数据的类型
var type = Object.prototype.toString.call(data).slice(8,-1);
instanceof 对象
let a = {}
a instanceof Array
// false
a instanceof Object
// true
数组
[] instanceof Array
// true
[] instanceof Object
// true
typeof
类型 | 公式 | 结果 |
---|---|---|
[] | typeof [] | “object” |
{} | typeof {} | “object” |
“” | typeof “” | “string” |
null | typeof null | “object” |
NaN | typeof NaN | “number” |
0 | typeof 0 | “number” |
1 | typeof 1 | “number” |
“function” | typeof Object | “function” |
function a(){console.log(1)} | typeof a | “function” |
function a(){console.log(1)} | typeof a() | “undefined” |
cccc | typeof cccc | “undefined” |
false | typeof false | “boolean” |
true | typeof true | “boolean” |
0.1*0.2
0.020000000000000004
0.8*0.9
0.7200000000000001