Michaƫl Rouges (2013-08-23T07:04:50.000Z)
Hi all,

Thanks for your answers.

Domenic Denicola sent me an example by email, but I don't understand it all.

I waited for his response, but seemed busy, I turn back to you.

The sample :

http://traceur-compiler.googlecode.com/git/demo/repl.html#function%20postToMailingList%28{%0A%20%20%20%20email%20%3D%20%22es-discuss%40mozilla.org%22%2C%0A%20%20%20%20subject%20%3D%20%22Optional%20named%20arguments%22%2C%0A%20%20%20%20from%20%3D%20%22michael.rouges%40gmail.com%22}%20%3D%20{}%29%20{%0A%20%20console.log%28email%2C%20subject%2C%20from%29%3B%0A}%0A%0ApostToMailingList%28%29%3B%20%2F%2F%20uses%20all%20the%20defaults%0ApostToMailingList%28{}%29%3B%20%2F%2F%20same%0ApostToMailingList%28{%20email%3A%20%22public-script-coord%40w3.org%22%20}%29%3B%20%2F%2F%20overrides%20the%20default%20email

Several points seems obscure:

   - the *=* operator in the option object declaration
   - the role of *= {}* inside the parentheses of the function declaration
   - and the fact that you can decide to have an empty object, despite
   defaults *(line 9)*

Could you enlighten me, please? or advise me of an article on this subject?

Thanks in advance.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130823/b01ac93c/attachment.html>
forbes at lindesay.co.uk (2013-08-23T13:01:10.266Z)
Thanks for your answers.

Domenic Denicola sent me an example by email, but I don't understand it all.

I waited for his response, but seemed busy, I turn back to you.

The sample :

```js
function postToMailingList({
    email = '[email protected]',
    subject = 'Optional Named Arguments',
    from = '[email protected]'} = {}) {
  console.log(email, subject, from)
}

postToMailingList()  //uses all the defaults
postToMailingList({})//exactly the same
postToMailingList({email: '[email protected]'})//overrides the default e-mail
```

[view in traceur](http://traceur-compiler.googlecode.com/git/demo/repl.html#function%20postToMailingList%28{%0A%20%20%20%20email%20%3D%20%22es-discuss%40mozilla.org%22%2C%0A%20%20%20%20subject%20%3D%20%22Optional%20named%20arguments%22%2C%0A%20%20%20%20from%20%3D%20%22michael.rouges%40gmail.com%22}%20%3D%20{}%29%20{%0A%20%20console.log%28email%2C%20subject%2C%20from%29%3B%0A}%0A%0ApostToMailingList%28%29%3B%20%2F%2F%20uses%20all%20the%20defaults%0ApostToMailingList%28{}%29%3B%20%2F%2F%20same%0ApostToMailingList%28{%20email%3A%20%22public-script-coord%40w3.org%22%20}%29%3B%20%2F%2F%20overrides%20the%20default%20email)

Several points seems obscure:

   - the `=` operator in the option object declaration
   - the role of `= {}` inside the parentheses of the function declaration
   - and the fact that you can decide to have an empty object, despite
   defaults *(line 9)*

Could you enlighten me, please? or advise me of an article on this subject?

Thanks in advance.