您现在的位置是:首页 > 电脑技术查询 > web开发

关于javascript的重载,该怎么解决

编辑:chaxungu时间:2022-10-02 23:23:34分类:web开发

关于javascript的重载
请问这样的话子类不是根据参数列表的不同重载了a方法吗??
但是为什么输出是Child Method count undefined 呢??
不是应该根据参数列表的不同调用了从父类继承的a方法,输出Parent Method count吗??
请指教!~~
function Parent() {

this.a=function(){
alert("Parent Method count");
}}

Children.prototype = new Parent();

function Children() {
this.a = function(cc) {
alert("Child Method count" + cc);
}
}var c = new Children();c.a();

------解决方案--------------------
HTML code<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"><html><head> <title>new document</title> <script type="text/javascript"> function Parent() { this
------解决方案--------------------
javascript中只会进行方法的拷贝,而不会进行引用!