<script type="text/javascript">
//第四种实现方式 based by prototype
//他也支持多继承
function Father(){
}
function fun()
{
//window.alert(arguments[1]);
for(i in arguments)
{
window.alert("aa");
alert(i);
}
window.alert("sddddddddddddd");
}
fun(1,1,1,1,1);
Father.prototype.color = "red";
Father.prototype.showColor = function(){
alert(this.color);
};
function Father1(){
}
Father.prototype.color1 = "red";
Father.prototype.showColor1 = function(){
alert(this.color1);
};
function Child(){
}
Child.prototype = new Father();
var child = new Child();
child.showColor();
function Child1(){
}
Child1.prototype = new Father();
Child1.prototype = new Father1();
var child1 = new Child();
child1.showColor();
child1.showColor1();
</script>
javascript中的继承实现一------------基于prototype
最新推荐文章于 2024-07-03 09:00:00 发布