is'foo === bar;等于“如果(foo === bar){返回true}”
我知道这个问题属于“基础知识”的领域,但是我想了解该语言的内部工作。
我的问题是:
运算符'返回'评估后默认情况下表达式的值吗?
“返回”,就像我们要写的那样:
//some operation using == < > etc...
return result;
I know this question falls in the realm of "basics", however I'd like to understand the inner workings of the language.
My question is:
Do operators 'return' the expression's value by default after evaluation?
'return' as in if we were to write:
//some operation using == < > etc...
return result;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有一些差异。
foo === bar不返回任何东西,它仅计算布尔值。
您可以将其与返回语句结合使用,如果foo == bar,则可以将其返回true,否则为false。
如果(foo === bar){return true}仅在两个相等的情况下返回true,则如果foo不等于bar,则不会返回。
There is a slight difference.
foo===bar does not return anything, it only calculates a boolean value.
You can combine this with a return statement, foo===bar to return true if foo == bar, and false otherwise.
if (foo === bar){return true} ONLY returns true if the two are equal, it would return nothing if foo does not equal bar.