3 ms·
IRHydra2 is pretty good for it but has a learning curve. There is really no need for the arguments object in a world with default and rest parameters, and it h
by phpnode 11y ago
IRHydra2 is pretty good for it but has a learning curve.
There is really no need for the arguments object in a world with default and rest parameters, and it has always been an obstacle to performance, so I'm glad arrow functions don't use it.
- exogen 11y agoIt's not so much that arrow functions "don't use it" that I'm complaining about but rather that they change the meaning and thus have confusing results. Also, changing that example to use rest parameters: function foo() { const bar = (...abc) => { console.log(abc); console.log(arguments); }; bar('a', 'b', 'c'); } SyntaxError: 'arguments' object may not be used in conjunction with a rest parameter ...which, okay, hmmm, it's sort of attempting to help me avoid confusion here. But that...was not what I was expecting. It's really weird that all of a sudden, just by adding a rest parameter to my function, a reference to `arguments` becomes invalid syntax.
- bsimpson 11y agoWhere are you finding that? This is what I get from Chrome: foo(1, 2, 3) // ["a", "b", "c"] // [1, 2, 3] And this is what I get from https://babel.io/repl https://babel.io/repl : 'use strict'; function foo() { var _arguments = arguments; var bar = function bar() { for (var _len = arguments.length, abc = Array(_len), _key = 0; _key < _len; _key++) { abc[_key] = arguments[_key]; } console.log(abc); console.log(_arguments); }; bar('a', 'b', 'c'); }
- exogen 11y agoFirefox. Chrome has not released support for rest params yet (it's in beta).