1
0
mirror of https://github.com/ruanyf/es6tutorial.git synced 2025-05-24 18:32:22 +00:00

edit destructuring & class

This commit is contained in:
ruanyf 2015-11-16 21:36:29 +08:00
parent f05acc0c84
commit 3dcf078440
3 changed files with 3 additions and 22 deletions

View File

@ -793,27 +793,7 @@ var descriptor = Object.getOwnPropertyDescriptor(
"set" in descriptor // true "set" in descriptor // true
``` ```
上面代码中存值函数和取值函数是定义在html属性的描述对象上面这与ES5完全一致。 上面代码中,存值函数和取值函数是定义在`html`属性的描述对象上面这与ES5完全一致。
下面的例子针对所有属性,设置存值函数和取值函数。
```javascript
class Jedi {
constructor(options = {}) {
// ...
}
set(key, val) {
this[key] = val;
}
get(key) {
return this[key];
}
}
```
上面代码中Jedi实例所有属性的存取都会通过存值函数和取值函数。
## Class的Generator方法 ## Class的Generator方法

View File

@ -286,7 +286,7 @@ start // error: start is undefined
let obj = {}; let obj = {};
let arr = []; let arr = [];
({ foo: obj.prop, bar: arr[0] }) = { foo: 123, bar: true }; ({ foo: obj.prop, bar: arr[0] } = { foo: 123, bar: true });
obj // {prop:123} obj // {prop:123}
arr // [true] arr // [true]

View File

@ -27,6 +27,7 @@
- Benjamin De Cock, [Frontend Guidelines](https://github.com/bendc/frontend-guidelines): ES6最佳实践 - Benjamin De Cock, [Frontend Guidelines](https://github.com/bendc/frontend-guidelines): ES6最佳实践
- Jani Hartikainen, [ES6: What are the benefits of the new features in practice?](http://codeutopia.net/blog/2015/01/06/es6-what-are-the-benefits-of-the-new-features-in-practice/) - Jani Hartikainen, [ES6: What are the benefits of the new features in practice?](http://codeutopia.net/blog/2015/01/06/es6-what-are-the-benefits-of-the-new-features-in-practice/)
- kangax, [Javascript quiz. ES6 edition](http://perfectionkills.com/javascript-quiz-es6/): ES6小测试 - kangax, [Javascript quiz. ES6 edition](http://perfectionkills.com/javascript-quiz-es6/): ES6小测试
- Jeremy Fairbank, [HTML5DevConf ES7 and Beyond!](https://speakerdeck.com/jfairbank/html5devconf-es7-and-beyond): ES7新增语法点介绍
## let和const ## let和const