Javascript 中(==)与(===)区别
通过代码来说明是更容易的
if(3 == "3"){
console.log("They are the same");
} else {
console.log("They are not the same.");
}
OUTPUT:
They are the same
第 2 个示例:
if(3 === "3"){
console.log("They are the same");
} else {
console.log("They are not the same.");
}
OUTPUT:
They are not the same.
==
在比较前会进行类型的转换,而 ===
则会对类型与值都进行比较。