javascript:调用基类函数

Sin*_*rMJ 0 javascript extends class prototypal-inheritance ecmascript-6

我有以下代码,我试图从基类继承.为什么代码说identify()没有定义?它不应该从基类调用函数吗?

错误:ReferenceError:识别未定义source1.js:23:9

class TestBase {
    constructor() {
        this.type  = "TestBase";
    }

    run() {
        console.log("TestBase Run");
    }

    identify() {
        console.log("Identify:" + this.type);
    }
}

class DerivedBase extends TestBase {
    constructor() {
        super();
        this.type  = "DerivedBase";
    }

    run() {
        console.log("DerivedBase Run");
        identify();
    }
}

window.onload = function() {
  let derived = new DerivedBase();
  derived.run();
}
Run Code Online (Sandbox Code Playgroud)

小智 5

this在调用函数之前添加identify();

run() {
  console.log("DerivedBase Run");
  this.identify();
}
Run Code Online (Sandbox Code Playgroud)