javascript面向对象之对象的深入理解
本文进一步分析讲述了javascript面向对象之对象的深入理解。分享给大家供大家参考。具体分析如下:
javacript面向对象程序设计中,可以理解为一切都是对象。实例代码如下:
<scriptlanguage="javascript"type="text/javascript">
functionCat(){
}
varcat1=newCat();//创建类实例
cat1.name="小狗"; cat1.age=4; cat1.color="白色"; document.write(cat1.name);
document.writeln(cat1.constructor);//实例化后对象,是对象 document.writeln(typeof(cat1)+"<hr/>");
document.writeln(Cat.constructor);//原型对象本身也是对象 document.writeln(typeofCat+"<hr/>");
varb="hello";//字符串也是对象 document.writeln(b.constructor);//输出它的构造函数 document.writeln(typeofb+"<hr/>");
varc=123;//数值也是对象 document.writeln(c.constructor); document.writeln(typeofc+"<hr/>"); </script>
热门推荐
10 22届高考祝福语简短
11 比赛宣传祝福语简短精辟
12 领证结婚搞笑祝福语简短
13 嘉宾姐姐出嫁祝福语简短
14 娃娃感冒生日祝福语简短
15 企业开工花束祝福语简短
16 朋友妹妹高考祝福语简短
17 除夕时刻祝福语大全简短
18 欢送会祝福语 简短