The Number JavaScript object is a wrapper object allowing you to work with numerical values. A Number object is created using the Number() constructor. It can also be used to detect if a String is valid number.
Example – Number() returning valid number
<script> document.write(Number("123") + "<br>"); document.write(Number("12.3") + "<br>"); document.write(Number("") + "<br>"); document.write(Number("0x11") + "<br>"); // hex document.write(Number("0o11") + "<br>"); // octal </script>
Example – Number() returning NaN
<script> document.write(Number("foo") + "<br>"); document.write(Number("100a") + "<br>"); </script>