标签:div OLE tle doctype var dem script eof har
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>JavaScript typeof</title> </head> <body> <h3>typeof返回数据类型</h3> <p id="demo"></p> <p id="demo1"></p> <script type="text/javascript"> document.getElementById("demo").innerHTML = typeof "狗蛋" + "</br>" + // 返回 string typeof 1 + "</br>" + // 返回 number typeof true + "</br>" + // 返回 boolean typeof [1,2,3,4] + "</br>" + // 返回 object,数组是特殊的对象类型 typeof {name:"狗蛋", age:22}; // 返回 object var test = {name:"狗蛋1", age:22}; var test; var test1;//值为 undefined, 类型为 undefined;跟test1 = undefined;是一样的 var test2 = null;//值为 null(空), 但类型为对象 document.getElementById("demo1").innerHTML = typeof test + "</br>" + typeof test1 + "</br>" + typeof test2; </script> </body> </html>
标签:div OLE tle doctype var dem script eof har
原文地址:https://www.cnblogs.com/zhou0910/p/12215676.html