b2科目四模拟试题多少题驾考考爆了怎么补救
b2科目四模拟试题多少题 驾考考爆了怎么补救

js中substr_js中typeof_Js中indexof(2)

电脑杂谈  发布时间:2017-02-19 03:20:24  来源:网络整理

??????? 语法为 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

相关阅读
    发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

    热点图片
    拼命载入中...