下面给出的这段代码应该评估一个值是否强制为真或假。这是如何运作的?例如,如果我想知道一个字符串——“我的字符串”是否会被强制转换为真或假,我如何使用 来确定?我试图在下面的代码中用“我的字符串”替换 val 出现的任何地方function logTruthiness (val) {if (val) { console.log("Truthy!");} else { console.log("Falsy.");}}function logTruthiness ("my string") {if ("my string") { console.log("Truthy!");} else { console.log("Falsy.");}}error function logTruthiness ("my string") { SyntaxError: Unexpected string
添加回答
举报
0/150
提交
取消