Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
弱类型语言不需要类型转换,可以直接使用,何必类型转换。
如果您的问题是我认为的,这篇文章可能会有所帮助
Javascript 是弱类型的。
这意味着变量没有固定的类型。
但这并不意味着没有类型的值:javascript 中的值都有一个类型,可能是数字、字符串、对象(包括函数)等(请参阅此处的完整类型列表)。
因此,当您想要对特定值类型进行不自然的操作(例如将字符串解释为布尔值)时,需要进行转换。