解构赋值语法是一种JavaScript表达式,可以将数组中的值或对象中的属性解压缩为不同的变量. The destructuring assignment syntax is a JavaScript expression that makes it possible to unpack values from arrays, or properties from objects, into distinct variables.var a, b;({a, b} = {a: 10, b: 20});console.log(a); // 10console.log(b); // 20 简写属性名称var a = 'foo', b = 42, c = {};var o = {a, b, c}; var data = [{ id: 1, title: 'Derp', subtitle: 'Derp', another: 'Derp', bla: 42 }, { id: 2, title: 'Derp', subtitle: 'Derp', another: 'Derp', bla: 42 }], short = data.map(({ id, title, subtitle }) => ({ id, title, subtitle }));console.log(short); 这篇关于JavaScript ES6-仅采用嵌套JSON数组的某些键/部分的简便方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-30 07:35