Home
<!DOCTYPE html> <html> <body> <h1>Demo: JavaScript Number() Function</h1> <p id="p1">Number('100') = </p> <p id="p2">typeof(i)= </p> <p id="p3">Number('10.5') = </p> <p id="p4">typeof(f)= </p> <p id="p5">Number('0b100')= </p> <p id="p6">typeof(b) = </p> <script> var i = Number('100'); var f = Number('10.5'); var b = Number('0b100'); document.getElementById("p1").textContent += i; document.getElementById("p2").textContent += typeof(i); document.getElementById("p3").textContent += f; document.getElementById("p4").textContent += typeof(f); document.getElementById("p5").textContent += b; document.getElementById("p6").textContent += typeof(b); </script> </body> </html>
Result: