Number.constant
new Number(value)
The numeric value of the Number object being created. This argument will be converted to a number, if necessary.
The newly constructed Number object
The largest representable number.
The smallest representable number.
Special Not-a-Number value.
Special negative infinite value; returned on overflow.
Special infinite value; returned on overflow.
Convert a number to a string, using a specified radix (base).
Return the primitive numeric value contained by the Number object.
Numbers are a basic, primitive data type in JavaScript. In Navigator 3.0, however, JavaScript also supports the Number object, an object type that represents a primitive numeric value. JavaScript automatically converts between the primitive and object forms as necessary. In Navigator 3.0, you can explicitly create a Number object with the Number() constructor, although there is rarely any need to do so.
The Number() constructor is actually more commonly used as a place-holder for five useful numeric constants: the largest and smallest representable numbers, positive and negative infinity, and the special Not-a-Number value. Note that these values are properties of the Number() constructor function itself, not of individual number objects. For example, you use the MAX_VALUE property as follows:
biggest =index.html Number.MAX_VALUE
n =index.html new Number(2); biggest = n.MAX_VALUE
By contrast, the toString() method of the Number object is a method of each Number object, not of the Number() constructor function. As noted above, JavaScript automatically converts from primitive numeric values to Number objects whenever necessary. This means that we can use the toString() method with a variable that holds a number, even though that value is not actually an object:
value =index.html 1234; binary_value = n.toString(2);
What happens in this code is that JavaScript implicitly invokes the Number() constructor to convert the number n to a temporary Number object for which the toString() method can be invoked. It is this toString() method that is the main reason for the existence of the Number object in the first place.
file: /Techref/language/java/script/definitive/refp_265.htm, 7KB, , updated: 2019/10/14 15:00, local time: 2024/11/23 19:55,
3.133.108.47:LOG IN
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://techref.massmind.org/Techref/language/java/script/definitive/refp_265.htm"> [Chapter 21] Reference: Number</A> |
Did you find what you needed? |
Welcome to massmind.org! |
Ashley Roll has put together a really nice little unit here. Leave off the MAX232 and keep these handy for the few times you need true RS232! |
.