deconstructing

by joplomacedo

JavaScript

const arr = [
  [
    'banana',
    {
      quantity: 10,
      color: 'yellow',
      sweet: 0.7
    }
  ],
  [
    'apple',
    {
      quantity: 18,
      color: 'red',
      sweet: 0.6
    }
  ],
];


arr.forEach(([
fruit,
{
  quantity,
  ...details
}]) => {
  console.log('fruit', fruit)
  console.log('quantity', quantity)
  console.log('details', details);
})