问题:
Moderator note: Please resist the urge to edit the code or remove this notice. 主持人注意:请拒绝编辑代码或删除此通知的冲动。 The pattern of whitespace may be part of the question and therefore should not be tampered with unnecessarily. 空白模式可能是问题的一部分,因此不应该被不必要地篡改。 If you are in the "whitespace is insignificant" camp, you should be able to accept the code as is. 如果你在“空白是微不足道的”阵营,你应该能够接受原样。
Is it ever possible that (a== 1 && a ==2 && a==3)
could evaluate to true
in JavaScript? 是否有可能(a== 1 && a ==2 && a==3)
可以在JavaScript中评估为true
?
This is an interview question asked by a major tech company. 这是一家大型科技公司提出的面试问题。 It happened two weeks back, but I'm still trying to find the answer. 它发生在两周前,但我仍在努力寻找答案。 I know we never write such code in our day-to-day job, but I'm curious. 我知道我们从来没有在日常工作中写过这样的代码,但我很好奇。
解决方案:
参考一: https://stackoom.com/question/3GXGR/可以-a-a-a-评估为真吗参考二: https://oldbug.net/q/3GXGR/Can-a-1-a-2-a-3-ever-evaluate-to-true
来源:oschina
链接:https://my.oschina.net/u/4428122/blog/4462736