3 ms·
> In the first function ("print"), "arg" is just syntax sugar for "arguments[0]". So much so that they reflect one another: you can set `arguments[0]` and retr
by masklinn 6y ago
> In the first function ("print"), "arg" is just syntax sugar for "arguments[0]".
So much so that they reflect one another: you can set `arguments[0]` and retrieve that value from `arg`, and the other way around:
function foo(arg0, arg1) {
arg0 = "foo";
arguments[1] = "bar";
console.log(Array.from(arguments), arg0, arg1);
}
foo(1, 2)
will log
[ "foo", "bar" ] foo bar
Although in reality optimising engines treat `arguments` as a keyword of sorts: they will not reify the object if they don't have to. However this meant they had to deoptimise a fair bit before the "spread" arguments arrived as that was how you'd call your "super".