Javascript examples for Data Type:Data Type Cast
OriginalValue | Converted to Number | Converted to String | Converted to Boolean |
---|---|---|---|
["ten","twenty"] | NaN | "ten,twenty" | true |
<!DOCTYPE html> <html> <body> <p>Converting an array with two string element to other types:</p> <p id="demo" style="font-family:courier"></p> <script> var x = ["ten","twenty"]; document.getElementById("demo").innerHTML = "Number : " + Number(x) + "<br>" + "String : " + String(x) + "<br>" + "Boolean: " + Boolean(x); </script>//from ww w.jav a 2 s.c om </body> </html>