Joined December 2013
·

Aleksander Ciesiołkiewicz

Experienced Frontend and PHP Developer at Perform Group
·
Poland
·
·

@jailbot - all numbers in JavaSript are instances of Number.
Also NaN (not-a-number) is an instance of a Number.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number

Edit
One note here:
If you type e.g.
x = 3;
x won't be an instance of Number. It won't be an object at all. But if you try do deal with it as with a Number

x.toString();

x will be converted to Number on the fly.

@hauleth - yeah, I know it's a Number after all. The point of that tip was to show the different ways of solving single problem and using bitwise operations is just a fast way: http://jsperf.com/math-floor-vs-math-round-vs-parseint/33

I also wanted to point the differences between those methods so readers can be aware of those and avoid surprises in the future.

But thanks to you I have learned something new today - thank's for that ;]

@hauleth - it really is simple however it doesn't convert a string to an integer but to a floating-point number:

str = '3.75';
+str; // returns 3.75
Achievements
229 Karma
24,637 Total ProTip Views
Interests & Skills