如何优雅地在回调中使用ES6解构
const data = [ { sex: 1, age: 18, }, { sex: 0, age: 18 }, { sex: 0, age: 19 }, { sex: 1, age: 19 } ]; let result = data.filter(({ sex }, index) => sex === 0); let result2 = data.map(({ age }, index) => age);
如何优雅地在回调中使用ES6解构
const data = [ { sex: 1, age: 18, }, { sex: 0, age: 18 }, { sex: 0, age: 19 }, { sex: 1, age: 19 } ]; let result = data.filter(({ sex }, index) => sex === 0); let result2 = data.map(({ age }, index) => age);