Update README to clarify what versions of JavaScript are supported
Opened this issue · 7 comments
Please update README to clarify what versions of JavaScript are supported.
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?
- Expected output:
Meow, my name is Kitty
- Actual output:
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 6a2797b