Continuing woes in reading the ES6 spec language

Axel Rauschmayer axel at rauschma.de
Fri Sep 13 15:06:48 PDT 2013


>> * You can have default parameters before parameters without defaults.
> The spec explicitly states that any parameter without a default, but after another parameter that does have a default assignment implicitly has a default property of undefined

As an aside: This can be useful. For example:

```js
function getRandomInteger(lower = 0, upper) {
    return Math.floor(Math.random() * (upper - lower)) + lower;
}
```

Implementing this function in some other manner is much more complicated.

But I agree that you want to name parameters if there are more than 2.

-- 
Dr. Axel Rauschmayer
axel at rauschma.de

home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130914/74103b53/attachment.html>


More information about the es-discuss mailing list