5 ms·
...arguments object not being an Array is yet another JavaScript wart that causes nothing but special cases and complexity in optimization pipelines...
by doublerebel 11y ago
...arguments object not being an Array is yet another
JavaScript wart that causes nothing but special cases
and complexity in optimization pipelines...
So, why can't we make `arguments` into an immutable Array for ES7? Is there any compiler advantage to keeping the special case?
- phpnode 11y agoIt would not be a web compatible change so will never happen. Too much code relies on them being different.
- doublerebel 11y agoThat doesn't make sense. Plenty of features from ES6 and 7 on the server and other platforms have steamed ahead despite browser adoption.
- phpnode 11y agoThings regularly fail to make it due to web compat, e.g. Array.prototype.contains() was rejected.
- hajile 11y agoAlmost all ES5.1 code will run on a browser that implements ES2015. There are subtle breakages like there were when moving from ES3 to ES5.1, but affected code is rare (and probably bad anyway). If `arguments` were changed, it would break huge swaths of the web rather than a couple sites. While it would be nice to require everyone to re-write their website code, the cost would probably be in the hundreds of billions of dollars. The pragmatic choice is to leave it in place and discourage it's use. Maybe it can be deprecated in a couple decades.
- inglor 11y agoIf it was possible, we'd remove `arguments` altogether in favor of rest parameters. There is absolutely no reason to use `arguments` in ES2015 anyway.
- gefh 11y agoYep. If you need an unknown number of things put them in an array. The arguments object is just too complicated for perf critical code.