Javascript examples for Data Type:Data Type Cast
OriginalValue | Converted to Number | Converted to String | Converted to Boolean |
---|---|---|---|
1 | 1 | "1" | true |
<!DOCTYPE html> <html> <body> <p>Converting the number 1 to other types:</p> <p id="demo" style="font-family:courier"></p> <script> var x = 1;/* www. ja v a 2s . c om*/ document.getElementById("demo").innerHTML = "Number : " + Number(x) + "<br>" + "String : " + String(x) + "<br>" + "Boolean: " + Boolean(x); </script> </body> </html>