Number(null)
结果为:0
Number(undefined)
结果为:NaN
null == undefined
结果为:true
null === undefined
结果为:false
0.1 + 0.2 == 0.3
结果为:false
0/0
结果为:NaN
1/0
结果为:Infinity
parseInt("4568fis zj56")
Number("4568fis zj56")
结果为:4568、NaN
String({a:1})
String([1,2,3])
结果为:[object Object]、1,2,3
[NaN].indexof(NaN)
结果为:-1
let a = ""
if(a){
console.log("true")
}else{
console.log("false")
}
结果为:false
let a = 1
let b = a
a = 2
console.log(b)
结果为:1
let obj = {p1:1};
with (obj) {
p1 = 2;
p2 = 4;
}
console.log(obj.p1, obj.p2)
结果为:2,undefined
function test(a, a){
console.log(a)
}
test(1, 2);
结果为:2
let f1 = function (a) {
console.log("f1: " + a)
return a + 1;
}
let f2 = function (a) {
console.log("f2: " + a)
return a + 1;
}
let f3 = function (a) {
console.log("f3: " + a)
return a + 1;
}
let p = new Promise(function (resolve, reject) {
resolve(1)
})
p.then(f1).then(f2()).then(f3);
结果为:
f2: undefined
f1:1
f3:2