JavaScript Number() Function

The Number() function converts the object argument to a number that represents the object’s value.

If the value cannot be converted to a legal number, NaN is returned.

Syntax

Number(object)

Example

<script language="JavaScript">

var test1= new Boolean(true);
var test2= new Boolean(false);
var test3= new Date();
var test4= new String("999");
var test5= new String("999 888");

document.write(Number(test1)+ "<br />");
document.write(Number(test2)+ "<br />");
document.write(Number(test3)+ "<br />");
document.write(Number(test4)+ "<br />;");
document.write(Number(test5)+ "<br />");



</script>


Output

1
0
1312026384155
999
NaN
DOWNLOAD SOLUTION HERE