这个打字稿语法是什么?

时间:2016-06-11 12:58:15

标签: typescript

偶然发现了这段代码:

const { operator } = this;

来自https://github.com/ReactiveX/rxjs/blob/master/src/Observable.ts#L89

这是什么意思?

1 个答案:

答案 0 :(得分:4)

它是object destructuring。此

const { operator, other } = this;

相当于

const operator = this.operator;
const other = this.other;

它是从ES6借来的,有the same feature