Talk:JavaScript/Numbers

Confusions
I think the following is wrong:
 * A number is a type of variable which stores an integer

JavaScript's variables are typeless, so any variable can store anything. "A number" in JavaScript is the same as in natural language: it is a value composed of digits. I believe that in JavaScript there are two types of numbers, integers and floating point values, or "floats" for short; like in all other curly-brace languages, such as C, C++, Java, C# etc.. Rursus (talk) 20:04, 18 May 2010 (UTC)


 * No, I'm partially wrong: there are no integers in JavaScript, see WP:JavaScript syntax#Number. "Numbers" are floating point values only.

For the rest, the Math object exists since numbers are not objects. In  var a = 2; var b = 2; there is no meaning to first create one object whose value is 2 and then another object whose value is 2, 2 is always identical to 2 wherever the respective 2:s are created and accessed. There are no need to actually create 2:s, instead one can imagine that all numbers are already preexisting "objects", that might be added or subtracted to each other, but the designers of JavaScript didn't understand it that way. Therefore the Math object exists to "give access" to functions operating on numbers when they aren't real objects. Rursus (talk) 20:12, 18 May 2010 (UTC)