gpt4 book ai didi

javascript - 为什么 'false' 在 javascript 中是真实的?

转载 作者:搜寻专家 更新时间:2023-11-01 04:44:15 24 4
gpt4 key购买 nike

我知道空字符串在 javascript 中是假的,非空字符串在 javascript 中是真。

但是,为什么 'false' 在 javascript 中是真实的,规范中是否有任何明确的内容?这是性能问题还是在某些情况下您希望字符串 'false' 代表 true

最佳答案

is there anything explicit in the specification?

Yes :

The result is false if the argument is the empty String (its length is zero); otherwise the result is true.

关于javascript - 为什么 'false' 在 javascript 中是真实的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32720503/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com