源代码
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>享学课堂</title> </head> <body> <p>将具有两个字符串元素的数组转换为其他类型:</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> </body> </html>
运行结果