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

  1. <tfoot id='oeiSJ'></tfoot>

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

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

      • <bdo id='oeiSJ'></bdo><ul id='oeiSJ'></ul>

      Javascript“元组"符号:它的意义是什么?

      Javascript quot;tuplequot; notation: what is its point?(Javascript“元组符号:它的意义是什么?)

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

            <tfoot id='XINrB'></tfoot>

                <tbody id='XINrB'></tbody>

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

                本文介绍了Javascript“元组"符号:它的意义是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                在 wtfjs,我发现以下是合法的javascript.

                At wtfjs, I found that the following is legal javascript.

                ",,," == Array((null,'cool',false,NaN,4)); // true
                

                参数 (null,'cool',false,NaN,4) 对我来说看起来像一个元组,但 javascript 没有元组!

                The argument (null,'cool',false,NaN,4) looks like a tuple to me, but javascript does not have tuples!

                我的 javascript 控制台中的一些快速测试会产生以下结果.

                Some quick tests in my javascript console yields the following.

                var t = (null,'cool',false,NaN,4); // t = 4
                (null,'cool',false,NaN,4) === 4; // true
                (alert('hello'), 42); // shows the alert and returns 42
                

                它的行为似乎与分号 ; 分隔的语句列表完全一样,只是返回最后一条语句的值.

                It appears to behave exactly like a semicolon ; separated list of statements, simply returning the value of the last statement.

                在某处有描述此语法及其语义的参考吗?为什么会存在,即应该在什么时候使用?

                Is there a reference somewhere that describes this syntax and its semantics? Why does it exist, i.e. when should it be used?

                推荐答案

                你看到了 逗号运算符.

                逗号运算符计算其两个操作数(从左到右)并返回第二个操作数的值.

                The comma operator evaluates both of its operands (from left to right) and returns the value of the second operand.

                a,b,c,...,n 求值时的结果值将始终是最右边表达式的值,但是链中的 所有 表达式仍在评估中(从左到右).

                The resultant value when a,b,c,...,n is evaluated will always be the value of the rightmost expression, however all expressions in the chain are still evaluated (from left to right).

                这篇关于Javascript“元组"符号:它的意义是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                在开发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 在一年的第一天返回前一年)
              • <tfoot id='VwujQ'></tfoot>

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

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