js 原型继承

    xiaoxiao2022-06-30  53

    function A (){this.name='A'} function _extend(Class,parentClass){ if (typeof parentClass == "function"){ Class.prototype = new parentClass(); } return Class ; } var B = _extend(function (){this.name='B'},A); var bORef = new B(); log(bORef); log(bORef instanceof A); var C = _extend(function (){this.name='C'},B); var cORef = new C(); log(cORef); log(cORef instanceof A); var D = _extend(function (){this.name='D'},C); var dORef = new D(); log(dORef,); log(dORef instanceof A);

     

    转载请注明原文地址: https://ju.6miu.com/read-1125867.html

    最新回复(0)