运行 ❯
获取您的
自己的
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <body> <h1>JavaScript Operators</h1> <h2>The typeof Operator</h2> <p>The typeof operator returns the type of a variable, object, function or expression:</p> <p id="demo"></p> <script> document.getElementById("demo").innerHTML = "'John' is " + typeof "John" + "<br>" + "3.14 is " + typeof 3.14 + "<br>" + "NaN is " + typeof NaN + "<br>" + "false is " + typeof false + "<br>" + "[1, 2, 3, 4] is " + typeof [1, 2, 3, 4] + "<br>" + "{name:'John', age:34} is " + typeof {name:'John', age:34} + "<br>" + "new Date() is " + typeof new Date() + "<br>" + "function () {} is " + typeof function () {} + "<br>" + "myCar is " + typeof myCar + "<br>" + "null is " + typeof null; </script> </body> </html>