??????? 语法为 o instanceof A
??????? **/
??????? alert("typeof(1):" + typeof(1));//number
??????? alert("typeof(\"abc\"):" + typeof("abc"));//string
??????? alert("typeof(true):" +typeof(true));//boolean
??????? alert("typeof(2009-2-4):" + typeof(2009-2-4));//number
??????? alert("typeof(\"2009-2-4\"):" + typeof("2009-2-4"));//string
??????? alert("typeof(m):" + typeof(m));//undefined
??????? var d=new Date();
??????? alert("typeof(d):" + typeof(d));//object
??????? function Person(){};
??????? alert("typeof(Person):" + typeof(Person));//function
??????? var a=new Array();
??????? alert("typeof(a):" + typeof(a));//object
??????? alert("a instanceof Array:" + (a instanceof Array));
??????? var h=new Person();
??????? var o={};
??????? alert("h instanceof Person:" + (h instanceof Person));//true
??????? alert("h instanceof Object:" + (h instanceof Object));//true
??????? alert("o instanceof Object:" + (o instanceof Object));//true
??????? alert(typeof (h)); //object
???????
??????? /**
??????? js中constructor较少使用,如果不是搜索到相关construtor相关的资料,我之前从没有注意到js还有这个函数。
??????? 使用typeof的一个不好的地方就是它会把Array还有用户自定义函数都返回为object
??????? **/
??????? var j=2;
??????? alert(typeof(j));//number
??????? alert("j.constructor:" + j.constructor);//function …
??????? alert(typeof(j.constructor));//function
??? </script>
?
如果讲得有错误,欢迎纠正!
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-33246-2.html
从容得体的回答很加分
只知道黑别人
知道要害死多少人不