CARVIEW |
Select Language
HTTP/2 307
date: Sun, 12 Oct 2025 01:53:44 GMT
content-type: text/html
content-length: 59
location: https://how.dev/answers/what-is-destructuring-in-javascript
cf-ray: 98d2f71c8d3f1712-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: 43e3ac4d9cdd55c4a4f1106801f12e06
via: 1.1 google
alt-svc: h3=":443"; ma=86400
cf-cache-status: EXPIRED
set-cookie: __cf_bm=k783V5tnENKweDm3JwwEh.jGcCMcAixZ3FuL0EG4QQQ-1760234024-1.0.1.1-KhlMuFIiL4Hgy5w1MdR7cLOBl_g1ibnEenHN2M8AyHmSLZyh8R0iJd_f2ZmF2QIHvoYDCJQ3S_tSIQKhaZMfH9TtymIgCcVCFZzefvpBOqw; path=/; expires=Sun, 12-Oct-25 02:23:44 GMT; domain=.educative.io; HttpOnly; Secure; SameSite=None
vary: Accept-Encoding
strict-transport-security: max-age=31536000; includeSubDomains; preload
server: cloudflare
HTTP/2 200
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
x-cloud-trace-context: 88c45437915f919c0862e5915cdfc646
server: Google Frontend
via: 1.1 google
content-encoding: gzip
date: Sat, 11 Oct 2025 13:41:48 GMT
cache-control: public, max-age=300, stale-while-revalidate=604800
etag: W/"17ao1xlyat8rt8"
content-type: text/html; charset=utf-8
vary: Accept-Encoding
content-length: 78869
age: 43916
x-cache-status: stale
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