is'foo === bar;等于“如果(foo === bar){返回true}”

发布于 2025-01-29 12:58:51 字数 194 浏览 3 评论 0原文

我知道这个问题属于“基础知识”的领域,但是我想了解该语言的内部工作。

我的问题是:
运算符'返回'评估后默认情况下表达式的值吗?
“返回”,就像我们要写的那样:

//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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我早已燃尽 2025-02-05 12:58:51

有一些差异。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文