解释 ES2015 类中的继承概念
Explain the concept of inheritance in ES2015 classes
题目类型: 技术面试题
这是一道技术面试题,常见于澳洲IT公司面试中。
难度: easy
分类: Prototypes & Inheritance
标签: javascript, oop
参考答案摘要
TL;DR ES2015 类中的继承允许一个类扩展另一个类,使子类能够从父类继承属性和方法。这是使用 extends 关键字完成的。 super 关键字用于调用父类的构造函数和方法。这是一个快速示例: class Animal { constructor(name) { this.name = name; } speak() { console.log( ${this.name} makes a ...
本题提供 STAR 原则详细解答和技术解析,登录匠人学院学习中心即可查看完整答案。