King Tutankhamen

A century after the discovery of King Tutankhamun’s tomb in the Valley of the Kings of Egypt, archaeologists are continuing to unearth more artifacts and controversies of this mysterious youthful…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Destructuring Objects and Arrays in JavaScript

Getting only what you need, when you need it.

Javascript is a language that is used for all sorts of things. And each year, new features come to the popular language. Some are very niche, and some, could be very useful during regular programming, even if you don’t notice its use right away.

The destructuring syntax makes it easy to unpack values from arrays or object to assign them to a variable. A lot of React developers use it often when working with props. It allows them to just have the property names instead of having to prefix them with props every time.

You can also unpack items in an array in the same way, which is also used by React developers when working with states.

I will show a few examples of the code first. Destructuring arrays is done using square brackets, while destructuring objects is done using regular brackets. You can use the syntax almost anywhere, including function calls.

I do apologize for the lack of articles lately, and I very much love the support I’m getting lately. I am working on a few projects and am still continuing my studies, so it’s very busy for me lately.

Thank you so much for reading and have an exquisite day.

Support me by supporting Medium and becoming a member. It helps me out a lot, it won’t cost you extra, and you can read as many Medium articles as you like!

Add a comment

Related posts:

NFT important to the music industry?

Music NFTs are allowing musician and artistes to create new possibilities and experiences with their fans. Musicians are continuing to be creative with what they offer to their fan bases…

Introduction to Trackers

Object tracking is one of the foremost important and common problem in computer vision that has shown to have various applications in the areas such as traffic monitoring, robotics, autonomous…

The Curse of Atuk

Some consider the unproduced screenplay Atuk cursed. Based on Mordecai Richler’s 1963 novel The Incomparable Atuk, the story follows a young Inuit poet and native of Baffin Island. The titular…