ES6 解构 数组从数组中取元素1234567const names = ['Luke', 'Eva', 'Phil'];const [first] = names;console.log(first); // 'Luke'const [first, second] = names;console.log(first, second); // 'Luke' 'Eva' 元素缺失时的默认值12const [first, second, third, fourth='Martin'] = names;console.log(fourth); // 'Martin' 跳过数组中的元素12var [first, , second] = names;console.log(first, second); // 'Luke' 'Phil' 分配数组中剩下的给某元素12var [first, ...rest] = names;console.log(rest); // ['Eva','Phil'] 对象12345678const person = { name: 'Luke', age: '24', facts: { hobby: 'Photo', work: 'Software Developer' }} 从对象中提取数据12const {name, age} = person;console.log(name, age); // 'Luke' '24' 提取嵌套值12const {facts: {hobby}} = person;console.log(hobby); // 'Photo' 数据缺失时的默认值12const {hometown = 'Unknown'} = person;console.log(hometown); // 'Unknown' 解构函数参数12345const toString = ({name, age}) => { return `${name} is ${age} years old`;}toString(person); // Luke is 24 years old Newer 滚动 scroll 性能优化 Older min-height的百分比