zlx362211854 / daily-study

每日一个知识点总结,以issue的形式体现
10 stars 6 forks source link

97. What's the output and why? #153

Open goldEli opened 4 years ago

goldEli commented 4 years ago
let a = 3;
let b = new Number(3);
let c = 3;

console.log(a == b);
console.log(a === b);
console.log(b === c);
nanslee commented 4 years ago
let a = 3;
let b = new Number(3);
let c = 3;

// true , 隐式类型转换
console.log(a == b); 
// false , new Number() 返回包装过的实例对象,非原始类型数据
console.log(a === b);
// false , 同上
console.log(b === c);
goldEli commented 4 years ago
let a = 3;
let b = new Number(3);
let c = 3;

console.log(a == b); // true 进行了转换
console.log(a === b);// false new Number(3) 并不是一个 number 类型,而是一个 object
console.log(b === c);// false 同上
zlx362211854 commented 4 years ago