ES6 in Action: Destructuring Assignment
解构赋值
In essence, ECMAScript 6 (ES2015) destructuring assignment allows you
to extract individual items from arrays or objects and place them into
variables using a shorthand syntax.
ES6允许按照一定模式,从数组和对象(以及字符串、数值、布尔值、函数参数等)中提取值,按照对应位置给变量进行赋值,这被称为解构赋值。
1. 数组解构
1 | var myArray = ['a', 'b', 'c']; |