CARVIEW |
Select Language
HTTP/2 307
date: Sat, 11 Oct 2025 13:41:47 GMT
content-type: text/html
content-length: 59
location: https://how.dev/answers/what-is-destructuring-in-javascript
cf-ray: 98cec6ea5855ccbb-BLR
cache-control: public, max-age=300, stale-while-revalidate=604800
referrer-policy: strict-origin-when-cross-origin
x-app-version: v251008-h-251010-1202
x-content-type-options: nosniff
x-frame-options: SAMEORIGIN
x-xss-protection: 1; mode=block
x-app-type: Learn
x-robots-tag: all
x-nextjs-cache: MISS
x-cloud-trace-context: e0542e7ac2960981c41fcbd84d00b31b;o=1
via: 1.1 google
alt-svc: h3=":443"; ma=86400
cf-cache-status: MISS
set-cookie: __cf_bm=W89DGgN5r.__tzVv_TVjjEwuXtwfI9y9nJY0BMVivbA-1760190107-1.0.1.1-4Atjo5YexHURBpmFp2sf_vOdk7F0dad0zyydJ_Bk_Mkyv4WAI3aWeuY9x2ZtNgPUDnK0EYHFJ.z8VhJCWihArR0RqdTU21YEnH7w7bjJMb4; path=/; expires=Sat, 11-Oct-25 14:11:47 GMT; domain=.educative.io; HttpOnly; Secure; SameSite=None
vary: Accept-Encoding
strict-transport-security: max-age=31536000; includeSubDomains; preload
server: cloudflare
HTTP/2 200
cache-control: public, max-age=300, stale-while-revalidate=604800
referrer-policy: strict-origin-when-cross-origin
x-app-version: v251008-h-251010-1202
x-content-type-options: nosniff
x-frame-options: SAMEORIGIN
x-xss-protection: 1; mode=block
x-app-type: Learn
x-middleware-rewrite: /answers/howdev/what-is-destructuring-in-javascript
x-nextjs-cache: MISS
etag: W/"17ao1xlyat8rt8"
content-type: text/html; charset=utf-8
x-cloud-trace-context: 88c45437915f919c0862e5915cdfc646
date: Sat, 11 Oct 2025 13:41:48 GMT
server: Google Frontend
via: 1.1 google
vary: Accept-Encoding
content-encoding: gzip
x-cache-status: miss
alt-svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
What is destructuring in JavaScript? 

What is destructuring in JavaScript?
Destructuring is a feature introduced with ES6. A feature that enables you to break down a structure, like an array or object, and store its components in variables.
Destructuring arrays
Let’s see how destructuring works on arrays.
fruits = ["Apple","Banana","Melon","Plum"] //Array to be destructuredvar [fruit1, fruit2] = fruits //Destructuringconsole.log(fruit1)console.log(fruit2)
This is what happened in the code above
Let’s now see a few techniques to use destructuring efficiently:
fruits = ["Apple","Banana","Melon","Plum"] //Array to be destructuredvar [,fruit1,, fruit2] = fruits //Focus on the use of extra commas to skip through elementsconsole.log(fruit1)console.log(fruit2)
Selecting desired elements
Example1 of code above
Example2 of code above
Destructuring objects
Destructuring objects is slightly different from destructuring arrays.
var car = {category : "sports",color : "red",top_speed : 240} //object to be destructuredvar {top_speed, color} = car //console.log(top_speed)
Relevant Answers
Explore Courses
Free Resources
Copyright ©2025 Educative, Inc. All rights reserved