源代码
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>享学课堂</title> </head> <body> <h2>JavaScript typeof</h2> <p>typeof 运算符返回变量或表达式的类型.</p> <p id="demo"></p> <script> document.getElementById("demo").innerHTML = typeof "" + "<br>" + typeof "John" + "<br>" + typeof "John Doe" + "<br>" + typeof "John" + "Doe"; </script> </body> </html>
运行结果