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

      1. <small id='aFrd4'></small><noframes id='aFrd4'>

        <tfoot id='aFrd4'></tfoot>

        这是什么JS语法?表达式赋值?(x != null &amp;&amp; (y = x))

        What is this JS syntax? Assignment in expression? (x != null amp;amp; (y = x))(这是什么JS语法?表达式赋值?(x != null amp;amp; (y = x)))
          <tbody id='5Qqeq'></tbody>
      2. <i id='5Qqeq'><tr id='5Qqeq'><dt id='5Qqeq'><q id='5Qqeq'><span id='5Qqeq'><b id='5Qqeq'><form id='5Qqeq'><ins id='5Qqeq'></ins><ul id='5Qqeq'></ul><sub id='5Qqeq'></sub></form><legend id='5Qqeq'></legend><bdo id='5Qqeq'><pre id='5Qqeq'><center id='5Qqeq'></center></pre></bdo></b><th id='5Qqeq'></th></span></q></dt></tr></i><div id='5Qqeq'><tfoot id='5Qqeq'></tfoot><dl id='5Qqeq'><fieldset id='5Qqeq'></fieldset></dl></div>
        <tfoot id='5Qqeq'></tfoot>

            <bdo id='5Qqeq'></bdo><ul id='5Qqeq'></ul>
            • <small id='5Qqeq'></small><noframes id='5Qqeq'>

                • <legend id='5Qqeq'><style id='5Qqeq'><dir id='5Qqeq'><q id='5Qqeq'></q></dir></style></legend>
                • 本文介绍了这是什么JS语法?表达式赋值?(x != null &amp;&amp; (y = x))的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在使用这个 JS 插件,我遇到了一些我以前从未见过的语法.我明白它在做什么,但我不确定它为什么会起作用.

                  I'm working with this JS plugin, and I've encountered some syntax I've never seen before. I understand what it's doing, but I'm not sure why it works.

                  这是一个例子:

                  settings.maxId != null && (params.max_id = settings.maxId);
                  

                  这只是利用条件和单个 = 吗?这是 JS 常用的语法吗?

                  Is this just taking advantage of conditionals and the single = ? Is this common syntax for JS?

                  推荐答案

                  在 JavaScript 中,= 运算符是一个 表达式 并计算分配的值.因为它是一个表达式,它可以在任何允许使用表达式的地方使用即使它会产生副作用.因此:

                  In JavaScript the = operator is an expression and evaluates the assigned value. Because it is an expression it can be used anywhere an expression is allowed even though it causes a side-effect. Thus:

                  settings.maxId != null && (params.max_id = settings.maxId)
                  

                  意思是:如果 settings.maxId 不为空,那么 (只有这样,因为 && 是 短路) 评估右表达式 (params.max_id = settings.maxId) 进而导致 settings.maxId 的值被分配给 params.max_id.这更清楚写成:

                  Means: If settings.maxId is not null then (and only then, since && is short circuiting) evaluate the right-expression (params.max_id = settings.maxId) which in turn causes the value of settings.maxId to be assigned to params.max_id. This is much more clearly written as:

                  if (settings.maxId != null) {
                    params.max_id = settings.maxId
                  }
                  

                  编码愉快.

                  这篇关于这是什么JS语法?表达式赋值?(x != null &amp;&amp; (y = x))的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  Fetch multiple links inside foreach loop(在 foreach 循环中获取多个链接)
                  Backbone Fetch Request is OPTIONS method(Backbone Fetch Request 是 OPTIONS 方法)
                  Fetch API leaks memory in Chrome(Fetch API 在 Chrome 中泄漏内存)
                  How can I download and save a file using the Fetch API? (Node.js)(如何使用 Fetch API 下载和保存文件?(Node.js))
                  Send blob data to node using fetch, multer, express(使用 fetch、multer、express 将 blob 数据发送到节点)
                  Sending a custom User-Agent string along with my headers (fetch)(发送自定义用户代理字符串以及我的标头(获取))

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

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