美文网首页哥要学前端!!Web前端之路
每当我面试被问到原型继承的时候,总是写下这段代码

每当我面试被问到原型继承的时候,总是写下这段代码

作者: 3DMUND | 来源:发表于2016-03-22 16:11 被阅读127次
    function Fuck() {
      this.species = 'Not specified';
    };
    
    Fuck.prototype.fuck = function () {
      console.log('Fuck' + this.species);
    };
    
    function FuckHuman() {
      this.species = 'Human';
      Fuck.call(this);
    }
    
    
    FuckHuman.prototype = Object.create(Fuck.prototype);
    
    // Set the "constructor" property to refer to FuckHuman
    FuckHuman.prototype.constructor = FuckHuman;
    
    function FuckYou() {
      this.name = 'You';
      FuckHuman.call(this);
    }
    
    FuckYou.prototype = Object.create(FuckHuman.prototype);
    FuckYou.prototype.constructor = FuckYou;
    
    FuckYou.prototype.fuck = function () {
      console.log('Fuck ' + this.name);
    }
    
    var fuckYou = new FuckYou ();
    fuckYou.fuck();
    

    相关文章

      网友评论

      • GarenWang:其实函数名可以用中文,fuck改为草

      本文标题:每当我面试被问到原型继承的时候,总是写下这段代码

      本文链接:https://www.haomeiwen.com/subject/qwkllttx.html