欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 前端技术 > javascript >内容正文

javascript

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

发布时间:2025/7/14 javascript 44 豆豆
生活随笔 收集整理的这篇文章主要介绍了 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
-->

转载于:https://www.cnblogs.com/handboy/p/7148450.html

总结

以上是生活随笔为你收集整理的js1:对象的学习,构造函数,继承构造函数【使用教材:JavaScript深度剖析第2版】...的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。