运行 ❯
获取您
自己的
网站
×
更改方向
保存代码
更改主题,暗/亮
前往空间
<!DOCTYPE html> <html> <body> <h1>JavaScript Operators</h1> <h2>The typeof Operator</h2> <p>The typeof operator returns the type of a variable or an expression:</p> <p id="demo"></p> <script> document.getElementById("demo").innerHTML = "'John' is " + typeof "John" + "<br><br>" + "('John' + 'Doe') is " + typeof ("John" + "Doe") + "<br><br>" + "3.14 is " + typeof 3.14 + "<br><br>" + "33 is " + typeof 33 + "<br><br>" + "(33 + 66) is " + typeof (33 + 66) + "<br><br>" + "NaN is " + typeof NaN + "<br><br>" + "true is " + typeof true + "<br><br>" + "false is " + typeof false + "<br><br>" + "1234n is " + typeof 1234n + "<br><br>" + "Symbol() is " + typeof Symbol() + "<br><br>" + "x is " + typeof x; </script> </body> </html>