Skip to main content

Destructuring arrays and objects

@serverSerrverlesskiy

Destructuring in JavaScript is an assignment syntax that allows you to conveniently extract data from arrays and objects in one line.

Object destructuring#

object

Live Editor
Result
SyntaxError: Unexpected token (1:8)
1 : return ()
            ^

The properties title, group and quantity repeat the structure of the object fruit and copy their values into identical variables πŸ”” found in {...}. Therefore, if you swap the variables πŸ”” in {...}, then the code will work just as well, try swapping the variables πŸ”” in the example above.

Payment#

Now you are on a stripped-down version of the site, after subscribing to Patreon, you will get full access to the training course, as well as access to our server's private channels in Discord.

Download our mobile application or get tested in our JavaScript telegram bot, and also subscribe to our news.

Become a Patron!

Sumerian school

Links#

  1. Learn JavaScript
  2. MDN Web Docs
  3. Destructuring in ES6

Contributors ✨#

Thanks goes to these wonderful people (emoji key):


IIo3iTiv

πŸ“–

Dmitriy Vasilev

πŸ’΅

Resoner2005

πŸ› 🎨 πŸ–‹

Navernoss

πŸ–‹ πŸ› 🎨

Become a Patron!