Javascript examples for Data Type:Data Type Cast
OriginalValue | Converted to Number | Converted to String | Converted to Boolean |
---|---|---|---|
[10,20] | NaN | "10,20" | true |
<!DOCTYPE html> <html> <body> <p>Converting an array with two numeric elements to other types:</p> <p id="demo" style="font-family:courier"></p> <script> var x = [10,20];//w ww.ja v a2s.com document.getElementById("demo").innerHTML = "Number : " + Number(x) + "<br>" + "String : " + String(x) + "<br>" + "Boolean: " + Boolean(x); </script> </body> </html>