8 ms·
It'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,
by exogen 11y ago
It'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).