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

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

      <tfoot id='cTquf'></tfoot>

      1. <legend id='cTquf'><style id='cTquf'><dir id='cTquf'><q id='cTquf'></q></dir></style></legend>

        什么是 arguments 变量的实例?

        时间:2023-10-21
          <tbody id='iibwY'></tbody>

          <tfoot id='iibwY'></tfoot>

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

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

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

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

                1. 本文介绍了什么是 arguments 变量的实例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  MDN 说它是类似对象的数组" 但没有说明它是什么实例.

                  MDN says it is "an Array like object" but does not say what it is an instance of.

                  它不是 HTMLCollectionNodeList.

                  如果我调用 Object.prototype.toString.call(arguments) 它返回 "[object Arguments]"arguments instanceof Arguments 是一个错误.

                  If I call Object.prototype.toString.call(arguments) it returns "[object Arguments]" but arguments instanceof Arguments is an error.

                  那么 arguments 的实例是什么?

                  So what is arguments an instance of?

                  推荐答案

                  那么参数的实例是什么?

                  So what is arguments an instance of?

                  它是 Object 的一个实例.似乎没有任何公共 Arguments 构造函数可以与 instanceof 一起使用来以这种方式识别它.

                  It's an instance of Object. There does not appear to be any public Arguments constructor that you can use with instanceof to identify it that way.

                  如果你想唯一标识它,那么:

                  If you want to uniquely identify it, then:

                  Object.prototype.toString.call(arguments) === "[object Arguments]"
                  

                  是一种安全的识别方式.

                  is a safe way to identify it.

                  根据 EcmaScript 6 规范中的 第 9.4.4 节,arguments 对象要么是普通对象,要么是奇异对象.规范是这样说的:

                  Per section 9.4.4 in the EcmaScript 6 specification, the arguments object is either an ordinary object or an exotic object. Here's what the spec says:

                  大多数 ECMAScript 函数都使参数对象可用于它们的代码.根据函数定义的特点,它的参数对象要么是一个普通对象,要么是一个参数异国情调的物体.

                  Most ECMAScript functions make an arguments objects available to their code. Depending upon the characteristics of the function definition, its argument object is either an ordinary object or an arguments exotic object.

                  异国情调的论据object 是一个奇异的对象,其数组索引属性映射到调用其关联的形式参数绑定ECMAScript 函数.

                  An arguments exotic object is an exotic object whose array index properties map to the formal parameters bindings of an invocation of its associated ECMAScript function.

                  参数外来对象具有相同的内部插槽作为普通对象.它们还有一个 [[ParameterMap]] 内部投币口.普通参数对象也有一个 [[ParameterMap]] 内部其值始终未定义的插槽.对于普通参数对象[[ParameterMap]] 内部插槽仅由Object.prototype.toString (19.1.3.6) 来识别它们.

                  Arguments exotic objects have the same internal slots as ordinary objects. They also have a [[ParameterMap]] internal slot. Ordinary arguments objects also have a [[ParameterMap]] internal slot whose value is always undefined. For ordinary argument objects the [[ParameterMap]] internal slot is only used by Object.prototype.toString (19.1.3.6) to identify them as such.

                  由于它是一个异国情调"的对象,这本质上意味着它不遵循所有正常和预期的约定.例如,没有可以用来创建自己的对象的构造函数.而且,由于没有公共构造函数,这可能也解释了为什么没有您可以对其进行测试以唯一标识它的 instanceof.

                  Since it is an "exotic" object, that essentially means it doesn't follow all the normal and expected conventions. For example, there is no constructor function from which you can create your own object. And, because there is no public constructor function, that probably also explains why there's no instanceof that you can test on it to uniquely identify it.

                  这篇关于什么是 arguments 变量的实例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:splat over JavaScript 对象(带有新的)? 下一篇:为什么`const arg = arg;`会产生“初始化前无法访问"?错误?

                  相关文章

                2. <small id='27X5T'></small><noframes id='27X5T'>

                    <legend id='27X5T'><style id='27X5T'><dir id='27X5T'><q id='27X5T'></q></dir></style></legend>

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

                      <tfoot id='27X5T'></tfoot>
                        <bdo id='27X5T'></bdo><ul id='27X5T'></ul>