gpt4 book ai didi

javascript - 为什么typeof返回 “string1”或 “number1”

转载 作者:行者123 更新时间:2023-12-03 09:36:26 26 4
gpt4 key购买 nike

我遇到了typeof运算符的奇怪行为,无论在何处描述,我都没有找到任何东西。

typeof ([(0==0)+(0==0)]+[0])+((0==0)<<0) // "string1"

typeof (0^[(0==0)+(0==0)]+[0])+((0==0)<<0) // "number1"

typeof (0>>(0==0))+([0]+[(0==0)+(0==0)]^0) // "number2"

最佳答案

您将连续执行两个操作:

typeof ([(0==0)+(0==0)]+[0])   +   ((0==0)<<0)

"string" + ((0==0)<<0)

"string" + 1

"string1"

所有其他人都一样。

关于javascript - 为什么typeof返回 “string1”或 “number1”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20556432/

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