samlancashire Posted March 1, 2016 Share Posted March 1, 2016 Firefox 45 and Chrome 49 (both to be released in March) will have support for ECMAScript 6's class declaration, as well as constructor method, and super and extends keywords. This means we can now create classes in Javascript like this: class Sprite { constructor(health) { this.health = health; this.maxHealth = health; } get totalDamageTaken() { return this.maxHealth - this.health; } } class Enemy extends Sprite { constructor(health, damage) { super(health); this.damage = damage; } attack(sprite) { sprite.health -= this.damage; } } var player = new Sprite(10); var badguy = new Enemy(10, 2); badguy.attack(player); badguy.attack(player); console.log(player.health, player.totalDamageTaken); // 6, 4 If you want to try for yourself you can download Firefox Developer Edition, as it currently supports these features. For more information read MDN's documentation. Quote Link to comment Share on other sites More sharing options...
rich Posted March 1, 2016 Share Posted March 1, 2016 Also https://kpdecker.github.io/six-speed Quote Link to comment Share on other sites More sharing options...
dimumurray Posted March 3, 2016 Share Posted March 3, 2016 No support as of yet for ES6's new module system...bummer. Quote Link to comment Share on other sites More sharing options...
Gugis Posted March 3, 2016 Share Posted March 3, 2016 Whaaaaat? I'm using ES6 ~6 months and it's already working on Chrome What those releases will change? Quote Link to comment Share on other sites More sharing options...
mattstyles Posted March 3, 2016 Share Posted March 3, 2016 2 hours ago, Gugis said: Whaaaaat? I'm using ES6 ~6 months and it's already working on Chrome What those releases will change? If you are transpiling the browser never sees your ES2015 code. Otherwise you are only using the stuff that Chrome has supported for those 6 months. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.