Open ngocdaothanh opened 6 years ago
It's ES5 strict mode with some parts of ES6 implemented, and some parts of non-strict mode implemented. (And possibly some parts of ES5 missing).
Any thoughts on the best way to explain this?
It seems that class inheritance in ES6 is not supported.
It should be, atleast to some degree.
See https://github.com/codecombat/esper.js/blob/master/contrib/test-suites/js-corpus/classes.js
What's not working for you?
What's not working for you?
Meow, my name is Kitty
Meow, my name is undefined
class Animal {
constructor(name) {
this.name = name
}
}
class Cat extends Animal {
talk() {
console.log(`Meow, my name is ${this.name}`)
}
}
const kitty = new Cat('Kitty')
kitty.talk()
Is it easy to improve esper.js to support the example above?
Should be easy enough.
The bug here is that the Cat class doesn't inherit the constructor from Animal. For example the below works.
class Animal {
constructor(name) {
this.name = name
}
}
class Cat extends Animal {
constructor(name) { super(name); }
talk() {
console.log(`Meow, my name is ${this.name}`)
}
}
const kitty = new Cat('Kitty')
kitty.talk()
@ngocdaothanh Fixed in 6a2797b9dd6ea40f132930113d5927e07e1dd5b0
Please update README to clarify what versions of JavaScript are supported.