Clarification on function default param values

André Bargull andre.bargull at udo.edu
Tue Oct 1 00:03:57 PDT 2013


> >/  Brandon Benvie <mailto:bbenvie at mozilla.com  <https://mail.mozilla.org/listinfo/es-discuss>>
> />/  September 30, 2013 8:48 PM
> />/  I'm actually now really curious what the following does:
> />/
> />/  ```
> />/  function foo(x, y = (() => { arguments[0] = "foo"; return "bar" })()) {
> />/    return [x, y];
> />/  }
> /
> Easy: arguments is an early error in the body of an arrow.
>
> http://wiki.ecmascript.org/doku.php?id=harmony:arrow_function_syntax
>
> /be

This restriction is  not specified in the rev19 draft. Currently arrow 
functions don't have an own `arguments` binding, but instead access the 
outer functions `arguments` object, similar to `this`. Disallowing the 
identifier "arguments" in PrimaryExpressions also should imply 
disallowing "arguments" as a BindingIdentifier, which shifts arrow 
functions again into "almost strict-mode".

- André
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20131001/36d220cd/attachment-0001.html>


More information about the es-discuss mailing list