简体   繁体   中英

Destructure nested object with array

StripeId{
  customAttributes[{
    0: {customAttributeId: '1', dataType: 'text', id: null, name: "test", typeName: 'VALUE'}
    1: {customAttributeId: '2', dataType: 'text', id: null, name: testing, typeName: 'VALUE'}
    2: {customAttributeId: '3', dataType: 'text', id: null, name: test over, typeName: 'VALUE'}
   }]
}

    

I want to destructure the above object and I need to pull out the array object with the name "test over".

const {customAttributes} = StripeId;
const [firstItem: {customAttributeId, dataType, id, name, typeName}, secondItem, ...remainingItemsArr] = customAttributes;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM