0

如果我有一个大对象,并且需要该对象的所有属性,是否有一种快速的方法来解构该对象?

所以这:

const foo = {
  name1: 'foo',
  num1: 5,
  bool1: true
  friends1: ['bar', 'fizz', 'buzz'],
  name2: 'foo',
  num2: 5,
  bool2: true
  friends2: ['bar', 'fizz', 'buzz'],
  name3: 'foo',
  num3: 5,
  bool3: true
  friends3: ['bar', 'fizz', 'buzz'],
}

const {name1, num1, bool1, friends1, name2, num2, bool2, friends2, name3, num3, bool3, friends3} = foo;

变成这样:

const {*} = foo;
4

0 回答 0