当前位置: 代码迷 >> JavaScript >> 关于javascript的重载,该怎么解决
  详细解决方案

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

热度:82   发布时间:2012-02-17 17:50:42.0
关于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中只会进行方法的拷贝,而不会进行引用!
  相关解决方案