<tfoot id='miR5M'></tfoot>
    1. <small id='miR5M'></small><noframes id='miR5M'>

          <bdo id='miR5M'></bdo><ul id='miR5M'></ul>

      1. <i id='miR5M'><tr id='miR5M'><dt id='miR5M'><q id='miR5M'><span id='miR5M'><b id='miR5M'><form id='miR5M'><ins id='miR5M'></ins><ul id='miR5M'></ul><sub id='miR5M'></sub></form><legend id='miR5M'></legend><bdo id='miR5M'><pre id='miR5M'><center id='miR5M'></center></pre></bdo></b><th id='miR5M'></th></span></q></dt></tr></i><div id='miR5M'><tfoot id='miR5M'></tfoot><dl id='miR5M'><fieldset id='miR5M'></fieldset></dl></div>
        <legend id='miR5M'><style id='miR5M'><dir id='miR5M'><q id='miR5M'></q></dir></style></legend>

        什么是“x&amp;&amp;"foo()"?

        What is quot;x amp;amp; foo()quot;?(什么是“xamp;amp;foo()?)

          <legend id='5YLHD'><style id='5YLHD'><dir id='5YLHD'><q id='5YLHD'></q></dir></style></legend>
          • <bdo id='5YLHD'></bdo><ul id='5YLHD'></ul>
                <tbody id='5YLHD'></tbody>
                <tfoot id='5YLHD'></tfoot>

              • <small id='5YLHD'></small><noframes id='5YLHD'>

                  <i id='5YLHD'><tr id='5YLHD'><dt id='5YLHD'><q id='5YLHD'><span id='5YLHD'><b id='5YLHD'><form id='5YLHD'><ins id='5YLHD'></ins><ul id='5YLHD'></ul><sub id='5YLHD'></sub></form><legend id='5YLHD'></legend><bdo id='5YLHD'><pre id='5YLHD'><center id='5YLHD'></center></pre></bdo></b><th id='5YLHD'></th></span></q></dt></tr></i><div id='5YLHD'><tfoot id='5YLHD'></tfoot><dl id='5YLHD'><fieldset id='5YLHD'></fieldset></dl></div>
                  本文介绍了什么是“x&amp;&amp;"foo()"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我在其他地方看到 某处,

                  x &&foo();

                  等于

                  if(x){
                      foo();
                  }
                  

                  我对其进行了测试,他们确实做了同样的事情.
                  但为什么?x && 到底是什么?foo()?

                  I tested it and they really did the same thing.
                  But why? What exactly is x && foo()?

                  推荐答案

                  AND 和 OR 运算符都可以快捷键.

                  所以 && 仅在第一个表达式为真时才尝试第二个表达式(更具体地说,是真实的).第二个操作执行某些操作(无论 foo() 的内容如何)这一事实并不重要,因为它不会被执行除非第一个表达式的计算结果是真实的.如果是真的,那么被执行以尝试第二次测试.

                  So && only tries the second expression if the first is true (truth-like, more specifically). The fact that the second operation does stuff (whatever the contents of foo() does) doesn't matter because it's not executed unless that first expression evaluates to something truthy. If it is truthy, it then will be executed in order to try the second test.

                  相反,如果 || 语句中的第一个表达式为真,则第二个表达式不会被触及.这样做是因为整个语句已经可以被计算,无论第二个表达式的结果如何,该语句都将返回 true,因此它将被忽略并保持未执行.

                  Conversely, if the first expression in an || statement is true, the second doesn't get touched. This is done because the whole statement can already be evaluated, the statement will result in true regardless of the outcome of the second expression, so it will be ignored and remain unexecuted.

                  使用这样的快捷方式时要注意的情况当然是运算符的情况,其中定义的变量仍然计算为假值(例如 0)和真实值(例如 '零').

                  The cases to watch out for when using shortcuts like this, of course, are the cases with operators where defined variables still evaluate to falsy values (e.g. 0), and truthy ones (e.g. 'zero').

                  这篇关于什么是“x&amp;&amp;"foo()"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  在开发JS过程中,会经常遇到两个小数相运算的情况,但是运算结果却与预期不同,调试一下发现计算结果竟然有那么长一串尾巴。如下图所示: 产生原因: JavaScript对小数运算会先转成二进制,运算完毕再转回十进制,过程中会有丢失,不过不是所有的小数间运算会
                  问题描述: 在javascript中引用js代码,然后导致反斜杠丢失,发现字符串中的所有\信息丢失。比如在js中引用input type=text onkeyup=value=value.replace(/[^\d]/g,) ,结果导致正则表达式中的\丢失。 问题原因: 该字符串含有\,javascript对字符串进行了转
                  Rails/Javascript: How to inject rails variables into (very) simple javascript(Rails/Javascript:如何将 rails 变量注入(非常)简单的 javascript)
                  CoffeeScript always returns in anonymous function(CoffeeScript 总是以匿名函数返回)
                  Ordinals in words javascript(javascript中的序数)
                  getFullYear returns year before on first day of year(getFullYear 在一年的第一天返回前一年)
                  1. <tfoot id='gXtx4'></tfoot>
                    <i id='gXtx4'><tr id='gXtx4'><dt id='gXtx4'><q id='gXtx4'><span id='gXtx4'><b id='gXtx4'><form id='gXtx4'><ins id='gXtx4'></ins><ul id='gXtx4'></ul><sub id='gXtx4'></sub></form><legend id='gXtx4'></legend><bdo id='gXtx4'><pre id='gXtx4'><center id='gXtx4'></center></pre></bdo></b><th id='gXtx4'></th></span></q></dt></tr></i><div id='gXtx4'><tfoot id='gXtx4'></tfoot><dl id='gXtx4'><fieldset id='gXtx4'></fieldset></dl></div>

                      • <bdo id='gXtx4'></bdo><ul id='gXtx4'></ul>
                          <tbody id='gXtx4'></tbody>

                          <legend id='gXtx4'><style id='gXtx4'><dir id='gXtx4'><q id='gXtx4'></q></dir></style></legend>

                          <small id='gXtx4'></small><noframes id='gXtx4'>