DEV Community

Discussion on: Beginner's Guide To ES6 Destructuring

Collapse
 
donaldkelly17 profile image
Donald Kelly

I love the article. Heard of descructuring before but never really understood it until now. Thanks for posting. Just one comment about this bit of code:

  const food = ['🍕', '🌭', '🍔', '🍍', '🍓']
  const [pineapple, strawberry] = food
  console.log(pineapple, strawberry) // 🍍 🍓

Would this not console log the Pizza and Hotdog? Or need to add three commas to the destructuring before pineapple to ignore the first three items - as you discuss later - if pineapple and strawberry is required.

Collapse
 
themarcba profile image
Marc Backes

Hi! I'm happy that my content helps you understanding JavaScript. That's nice to hear.

Indeed you're right about the pizza and the hotdog. My example on that part was wrong. I corrected it. Thanks for pointing it out!