为什么这里没有类型强制?

时间:2016-10-22 19:44:31

标签: javascript boolean type-coercion

我对类型强制的理解是,当操作数具有不同的数据类型时,其中一个将转换为另一个操作数的“等效”值。

x = true;

y = "true"; // This should be converted to boolean or should be truthy by default

if (x == y){console.log("Type coercion works")}

0 个答案:

没有答案
相关问题