js 继承 函数

1. 为了简化类的声明 ,可以将派生子类的过程包装在名为extend的函数中;

function extend(subClass,superClass){
    var F = function(){};
    F.prototype = superClass.prototype;
    subClass.prototype = new F();  
    subClass.prototype.constructor = subClass;
}

2. clone 函数

function(object){
    function F(){};
   F.prototype = object;
   return new F;
}    

 

posted @   Terre  阅读(425)  评论(0编辑  收藏  举报
努力加载评论中...

风光无限好

点击右上角即可分享
微信分享提示