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

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

        如何在 JavaScript 中取消移位或添加到参数对象的开头

        How to unshift or add to the beginning of arguments object in JavaScript(如何在 JavaScript 中取消移位或添加到参数对象的开头)
        <legend id='ffU66'><style id='ffU66'><dir id='ffU66'><q id='ffU66'></q></dir></style></legend>

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

          <tfoot id='ffU66'></tfoot>

        1. <i id='ffU66'><tr id='ffU66'><dt id='ffU66'><q id='ffU66'><span id='ffU66'><b id='ffU66'><form id='ffU66'><ins id='ffU66'></ins><ul id='ffU66'></ul><sub id='ffU66'></sub></form><legend id='ffU66'></legend><bdo id='ffU66'><pre id='ffU66'><center id='ffU66'></center></pre></bdo></b><th id='ffU66'></th></span></q></dt></tr></i><div id='ffU66'><tfoot id='ffU66'></tfoot><dl id='ffU66'><fieldset id='ffU66'></fieldset></dl></div>
            <bdo id='ffU66'></bdo><ul id='ffU66'></ul>
                <tbody id='ffU66'></tbody>
                  本文介绍了如何在 JavaScript 中取消移位或添加到参数对象的开头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我刚刚学习了 弹出第一个元素的约定arguments 数组(我也学到了其实是一个Object).现在我需要做相反的事情.我需要使用 unshift 操作将值添加到 arguments 数组(或 Object 像数组一样)的开头.这可能吗?我试过了:

                  I've just learned the convention for popping off the first element of the arguments array (which I also learned is actually an Object). Now I need to do the opposite. I need to use an unshift operation to add a value to the beginning of the arguments array (or Object acting like an array). Is this possible? I tried:

                  Array.prototype.unshift.apply('hello', arguments);
                  

                  这对 arguments 没有任何影响.

                  That had no effect on arguments whatsoever.

                  推荐答案

                  1. 使用 .call() 而不是 .apply() 来调用 unshift()

                  arguments 设置为 unshift()

                  'hello' 设置为 unshift()

                  <小时>

                  Array.prototype.unshift.call(arguments, 'hello');
                  

                  <小时>

                  正如@lonesomeday 所指出的,您可以使用 .apply() 而不是 .call(),但您需要传递一个类似数组的参数作为第二个争论.因此,在您的情况下,您需要将 'hello' 包装在一个数组中.


                  As @lonesomeday pointed out, you can use .apply() instead of .call(), but you need to pass an array-like argument as the second argument. So in your case, you'd need to wrap 'hello' in an Array.

                  这篇关于如何在 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 在一年的第一天返回前一年)
                  <legend id='yMMqS'><style id='yMMqS'><dir id='yMMqS'><q id='yMMqS'></q></dir></style></legend>

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

                        • <bdo id='yMMqS'></bdo><ul id='yMMqS'></ul>
                            <tbody id='yMMqS'></tbody>
                        • <small id='yMMqS'></small><noframes id='yMMqS'>