Destructuring array of objects in es6
问题 In es6, how can i simplify the following lines using destructuring?: const array0 = someArray[0].data; const array1 = someArray[1].data; const array2 = someArray[2].data; 回答1: Whether using destructuring would actually be a simplification is debatable but this is how it can be done: const [ { data: array0 }, { data: array1 }, { data: array2 } ] = someArray Live Example: const someArray = [ { data: 1 }, { data: 2 }, { data: 3 } ]; const [ { data: array0 }, { data: array1 }, { data: array2 } ]