diff --git a/es6.md b/es6.md index b4beb7deb..bf6e2ca79 100644 --- a/es6.md +++ b/es6.md @@ -121,6 +121,33 @@ gen.next().value // 1 gen.next().value // 2 ``` +### [Classes](http://babeljs.io/docs/learn-es6/#classes) +Syntactic sugar for prototypes. + +```js +class Circle extends Shape { + // ctor + constructor(radius) { + this.radius = radius; + } + + // methods + getArea() { + return Math.PI * 2 * this.radius; + } + + // calling super methods + expand(n) { + return super.expand(n) * Math.PI; + } + + // static methods + static createFromDiameter(diameter) { + return new Circle(diameter / 2); + } +} +``` +
## Stable in Babel @@ -188,7 +215,7 @@ greet({ name: "Larry", greeting: "Ahoy" }); ``` ### [Function arguments](http://babeljs.io/docs/learn-es6/#default-rest-spread) -Default, rest, spread. +Default, rest, spread. (iojs: `--harmony-rest-parameters`) ```js // Default arguments @@ -232,33 +259,6 @@ readFile('text.txt', (err, data) => { numbers.map(n => n * 2) ``` -### [Classes](http://babeljs.io/docs/learn-es6/#classes) -Syntactic sugar for prototypes. - -```js -class Circle extends Shape { - // ctor - constructor(radius) { - this.radius = radius; - } - - // methods - getArea() { - return Math.PI * 2 * this.radius; - } - - // calling super methods - expand(n) { - return super.expand(n) * Math.PI; - } - - // static methods - static createFromDiameter(diameter) { - return new Circle(diameter / 2); - } -} -``` - ### [For..of iteration](http://babeljs.io/docs/learn-es6/#iterators-for-of) For iterating through generators and arrays.