Continuing woes in reading the ES6 spec language

Axel Rauschmayer axel at
Fri Sep 13 15:36:17 PDT 2013

>> ```js
>> function getRandomInteger(lower = 0, upper) {
>>    return Math.floor(Math.random() * (upper - lower)) + lower;
>> }
>> ```
> This doesn't do what you appear to think it does.  In particular,
> calling it with "getRandomInteger(5)" is *not* equivalent to calling
> it with "getRandomInteger(0, 5)", it's equivalent to calling it with
> "getRandomInteger(5, undefined)".
> This is precisely what the spec section you've quoted says, so I'm not
> sure how you're confused on this point.

Thanks! I didn’t look at the spec section, I (incorrectly) assumed I knew how they worked. Then I don’t see a use case for this, I’d find it confusing.

Dr. Axel Rauschmayer
axel at


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list