ecmascript 5 - For Javascript, what prevents modern implementation not to treat arguments as a real array? -


I think this is an outdated JavaScript behavior (Crokeford said that this is a design error) Inside, logic is like an array, except that it is not a real array, so array methods can not be applied to it:

  function foo () {Console.log (arguments.slice (1))} / / Foo (1,2,3) will not work;   

And I just tried it on the latest Firefox and Chrome, and it will not work on both of them. Therefore we may have to use

  function fu () {console.log (Array.prototype.slice.call (argument, 1))} foo (1,2,3);   

But why do not make any real array in the modern code logic ? Probably should not be any program which depends on arguments is not the actual array? Now what can be the reason for not making this a real array?

One reason I can think, if the programmers start treating it as an array, the code will not work in the old browsers, but there are other things in ECMA-5 which are also in older browsers. Will not work.

In the development of ECMAScript 5 for a very long time, the logic object was going to inherit all the array. The prototype method but in September 2009, the "final draft" of ES5 approved by TCL did not have this facility.

In August 2009, Apple's Oliver Hunt posted the discussion of ES5 to the mailing list

I created Argit objects from Arabic to WebKit I apply the logic to make it tomorrow on Friday and quickly changed the prototype. A serious / incompatibility with JES ... it breaks down to very few Apple sites and NASA GOV - ... these Due to breakdown of sites, due to a large compatibility problem
a large enough Seems Ustkaly that kind of behavior array - Ararf is not possible to attempt to return to the argument.

The rest of TCL was agreed with Oliver's assessment and this facility was removed from the final draft.

Perhaps, such code has disappeared from the web sufficiently the proposed ES5 solution will work today. However, it does not matter because the rest of the ES6 parameters are a better solution to the problem and a completely new syntax feature which can not be any compatibility problem behind the existing code.

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -