Skip to content
New issue

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

Update README to clarify what versions of JavaScript are supported #13

Open
ngocdaothanh opened this issue Jun 11, 2018 · 7 comments
Open

Comments

@ngocdaothanh
Copy link

Please update README to clarify what versions of JavaScript are supported.

@basicer
Copy link
Member

basicer commented Jun 13, 2018

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?

@ngocdaothanh
Copy link
Author

It seems that class inheritance in ES6 is not supported.

@basicer
Copy link
Member

basicer commented Jun 17, 2018

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?

@ngocdaothanh
Copy link
Author

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()

@ngocdaothanh
Copy link
Author

Is it easy to improve esper.js to support the example above?

@basicer
Copy link
Member

basicer commented Jun 20, 2018

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()

@basicer
Copy link
Member

basicer commented Jun 20, 2018

@ngocdaothanh Fixed in 6a2797b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants