源代码
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>享学课堂</title> </head> <body> <p>typeof 运算符返回变量或表达式的类型.</p> <button onclick="myFunction()">试试</button> <p id="demo"></p> <script> function myFunction() { var y = "5"; var x = + y; document.getElementById("demo").innerHTML = typeof y + "<br>" + typeof x; } </script> </body> </html>
运行结果