logo
Search
showing results for - "how destructuring works in javascript"
Ignacio
24 Jun 2017
1//destructuring in javascript
2const objA = {
3 prop1: 'foo',
4 prop2: {
5   prop2a: 'bar',
6   prop2b: 'baz',
7 },
8};
9
10// Deconstruct nested props
11const { prop1, prop2: { prop2a, prop2b } } = objA;
12
13console.log(prop1);  // 'foo'
14console.log(prop2a); // 'bar'
15console.log(prop2b); // 'baz'
similar questions
how to destructuring array in javascript 3fobject destructuringobject destructuringjs destructuring explaineddestructuring in javascriptobject destructuring examplejavascript array destructuringjavascript object destructingjs destructuringjsdoc object destructuringobject destructuring javascriptdestructuring objectsdestructuring javascriptarray destructuringdestructuring object in javascriptdestructuring objects jsobject destructuring to function parameters
queries leading to this page
array destructuring javascriptdestructuring in javascriptobject destructuringvariable default value js using destructuringdestruct syntax in javascriptjs destructuring default valuedestructuring in javascript w3schoolshow destructuring works in javascript
privacy policyterms of useinstagram
Crafted with  ♥  for everyone

sign in to continue
your answer for
you will get a confirmation link on this - you will have to click that for successful submission of your answer. we require this to keep the website free of spam, bots and unhelpful content
please ensure to add code which is syntactically corrent and executes properly
sign in to continue
ask question on maxinterview
you will get a confirmation link on this - you will have to click that for successful submission of your question. we require this to keep the website free of spam, bots and unhelpful content
please be clear, to the point and respectful
sign in to continue