On 05/15/2014 05:58 PM, ajvinc...@gmail.com wrote:
Re: readability, that's something to think about, but when I write code like 
this:

     if ((typeof num != "number") ||
         (Math.floor(num) != num) ||
         isNaN(num) ||
         (num < 0) ||
         Math.abs(num) == Infinity) {
       throw new Error("This need to be a non-negative whole number");
     }

Well, it adds up.  :)  Even now I can replace the fifth condition with 
!Number.isFinite(num).
>

One could use "if ((num | 0) !== num) { ... }". That should be equivalent for 32-bit unsigned integers.

HTH
Ms2ger


_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to