Number.valueOf()
JavaScript 1.1+, Jscript 3.0+ Nav3+, NES2+, IE4+ Syntax
number.valueOf()
Description
The valueOf method of the Number object is used to get the primitive value of a Number object as a number data type.
Example
Listing 6.190 shows an example for the valueOf method. A Number object is created and set to myNum. The document then outputs the result of performing a valueOf function on the number.
Listing 6.190 Example of Number.valueOf() Method
<html> <body> <script language="JavaScript1.1"> <!–– Hide // create a new number object myNum = new Number(24) // output the valueOf result. document.write("The value of myNum is: " + myNum.valueOf()); // End Hide ––> </script> </body> </html> |
Get Pure JavaScript now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.