We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
function Father() { this.color = 'yellow' } function Child() { this.name = 'childName' Father.call(this) } Child.prototype.__proto__ = Father.prototype Child.prototype.constructor = Child var child1 = new Child() console.log(child1)
class Father { constructor(name, age) { this.name = name; this.age = age; } getName() { return this.name } } class Child extends Father { constructor(name, age, job) { super(name, age) this.job = job } getJob() { return this.job } getNameAndJob() { return super.getName() + this.getJob() } } var a = new Child('Tom', '20', 'IT') console.log(a.name) ==>Tom console.log(a.age) ==>20 console.log(a.job) ==>IT console.log(a.getName()) ==>Tom console.log(a.getJob()) ==>IT console.log(a.getNameAndJob()) ==>TomIT
The text was updated successfully, but these errors were encountered:
No branches or pull requests
ES5 寄生组合继承
ES6 的继承实现
The text was updated successfully, but these errors were encountered: