欢迎访问我的博客 https://javascript.shop

js1:对象的学习,构造函数,继承构造函数【使用教材:JavaScript深度剖析第2版】

原文发布时间为:2008-11-08 —— 来源于本人的百度文章 [由搬家工具导入]

<html>
<head>
<title>js</title>
<script language="JavaScript">
   function Company(){
this.cname="aa";
this.products="bb";
}

function Sales(){
this.fromwhere="cc";
this.reps="50";
this.meth=disp;
}
Sales.prototype=new Company();
var t1="t1";
function disp(){
t2="t2";
var t3="t3";
document.write(this.reps+"<br>");
document.write(this.cname);
document.write(this.fromwhere);
document.write(this.products);
}
</script>
</head>
<body>
<script language="JavaScript">
var s1=new Sales();
s1.meth();
Sales.prototype.size="78";
document.write(t1);
document.write(t2);
document.write(t3);
</script>

</body>
</html>

<!--结果为
50
aaccbbt1t2
-->

posted @ 2017-07-11 00:33  孑孓子  阅读(86)  评论(0编辑  收藏  举报
欢迎访问我的博客 https://javascript.shop