How to use Number in JavaScript
This article describe about Number() Function in JavaScript.
Number() Function in JavaScript
This function convert the object argument to a number that represents the object's value.
Note: Return NaN, if the value cannot be converted to a legal number.
Syntax
Parameter |
Description |
object |
Optional. JavaScript object, return 0 if no argument specified. |
Example
<!DOCTYPE html>
<html>
<body>
<script type="text/javascript">
var t1 = new Boolean(true);
var t2 = new Boolean(false);
var t3 = new Date();
var t4 = new String("777");
var t5 = new String("777 888");
document.write(Number(t1) + "<br />");
document.write(Number(t2) + "<br />");
document.write(Number(t3) + "<br />");
document.write(Number(t4) + "<br />");
document.write(Number(t5) + "<br />");
</script>
</body>
</html>
|
Output
You may also want to read these related articles Click here
Ask Your Question
Got a programming related question? You may want to post your question here
Programming Answers here