Ext extend 疑问

 extend: function () {
    // inline overrides
    var io = function (o) {
        for (var m in o) {
            this[m] = o[m];
        }
    };
    var oc = Object.prototype.constructor;
    return function (sb, sp, overrides) {
        if (typeof sp == 'object') {
            overrides = sp;
            sp = sb;
            sb = overrides.constructor != oc ? overrides.constructor : function () {
                sp.apply(this, arguments);
            };
        }
        var F = function () {},
            sbp, spp = sp.prototype;
        F.prototype = spp;
        sbp = sb.prototype = new F();
        sbp.constructor = sb;
        sb.superclass = spp;
        if (spp.constructor == oc) {
            spp.constructor = sp;
        }
        sb.override = function (o) {
            Ext.override(sb, o);
        };
        sbp.override = io;
        Ext.override(sb, overrides);
        sb.extend = function (o) {
            Ext.extend(sb, o);
        };
        return sb;
    };

 

//干嘛用的,难道就是 为了 sp = Object 时 ? 然而就算 sp == Object 也可以运行//的啊
                if(spp.constructor == oc){
                    spp.constructor=sp;
                }
 

 

看这里:已经完美解决了

简析 Extjs 类继承

你可能感兴趣的:(prototype,F#,ext)