Continuing woes in reading the ES6 spec language

Axel Rauschmayer axel at rauschma.de
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 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/cd4d2f3b/attachment.html>


More information about the es-discuss mailing list