🌐
Honeybadger
honeybadger.io › blog › javascript-destructuring
Destructuring in JavaScript - Honeybadger Developer Blog
April 6, 2023 - Now that you know how rest items work in JavaScript, let's look at mixed destructuring in the next section. Mixed destructuring is a combination of both object destructuring and array destructuring; it allows you to extract values from arrays and objects in a single destructuring assignment. For example, if you have an object with an array inside of it, you can destructure the object as well as the array with a single line:
🌐
JavaScript.info
javascript.info › tutorial › the javascript language › data types
Destructuring assignment
February 26, 2026 - The function might only require certain elements or properties. Destructuring assignment is a special syntax that allows us to “unpack” arrays or objects into a bunch of variables, as sometimes that’s more convenient.
Discussions

Help Understanding Object Destructuring in JavaScript
This is semantically no different than the following: const name = person.name; const age = person.age; const anotherName = person.anotherName; //doesnt exist on person const anotherAge person.anotherAge; //also doesnt exist person Since there is no key "anotherName" or "anotherAge" on the person object, so they resolve to undefined. The name of the variables have to match the key on the object being destructured. More on reddit.com
🌐 r/learnjavascript
20
20
August 25, 2024
javascript - How to destructure nested object - Stack Overflow
Destructuring Nested objects in javascript | Destructure second level parent and child Objects (2 answers) More on stackoverflow.com
🌐 stackoverflow.com
[AskJS] object destructuring vs dot notation. Performance and cohesiveness.
IMO if you're having trouble keeping track of a local variable in a function, your function is too big. Also, having trouble keeping track of whether a variable is from props or state (assuming react / redux ?) is mitigated by using mapStateToProps so that everything is from props. More on reddit.com
🌐 r/javascript
30
6
August 27, 2020
How can I solve this Object is possibly 'null' error when using array destructuring?

Your function either returns an APIError object, or a Response object, and never both. The best type to represent a mutually-exclusive-list-of-types is not an array, it's a union:

interface APIError {
  status: "error"
  value: string
}

interface Response<T> {
  status: "success"
  value: T
}

declare function apiRequest(): APIError | Response<MyResponseType>;
const apiResponse = await apiRequest();

if (apiResponse.status === "success") {
  // Response logic
} else {
  // Error logic
}
More on reddit.com
🌐 r/typescript
9
11
July 23, 2020
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Operators › Destructuring
Destructuring - JavaScript - MDN Web Docs - Mozilla
For array destructuring, it collects remaining elements of the iterable into a new array called rest (or any name you give it). For object destructuring, it copies all enumerable own properties of the object that are not already picked off by the destructuring pattern into a new object called rest.
🌐
Syncfusion
syncfusion.com › blogs › javascript › top 7 javascript object destructuring techniques
Top 7 JavaScript Object Destructuring Techniques | Syncfusion Blogs
December 19, 2024 - We can use this rest parameter in object destructuring as well. If there are many properties in an object, we can assign the essential values to variables and unpack all the remaining values to another object using the rest parameter. let languages = { language1 : 'Java', language2 : 'JavaScript', language3 : 'C', language4 : 'Python', language5 : 'C#', language6 : 'C++', language7 : 'Ruby' }; let { language1, language2, ...otherLanguages } = languages; console.log(language1); // Java console.log(language2); // JavaScript console.log(otherLanguages) ; /* { "language3": "C","language4" : "Python","language5": "C#","language6": "C++", "language7": "Ruby" } */
🌐
Reddit
reddit.com › r/learnjavascript › help understanding object destructuring in javascript
r/learnjavascript on Reddit: Help Understanding Object Destructuring in JavaScript
August 25, 2024 -

I'm currently learning JavaScript and practicing some code, but I'm getting a bit confused about how object destructuring works. Below is the code snippet I'm working with:

const person = {
  name: "Harmeet",
  age: 40
}

const { name, age} =  person;

console.log(name); // prints Harmeet
console.log(age); // prints 40

const {anotherName, anotherAge} = person;

console.log(anotherName); // prints undefined
console.log(anotherAge); // prints undefined

Could someone explain how the object destructuring is working in this context? Specifically, I'm confused about during the second time assignment, why object descrtion prints undefined instead of values? Any detailed explanation or examples would be greatly appreciated!

🌐
Dmitri Pavlutin
dmitripavlutin.com › javascript-object-destructuring
How to Use Object Destructuring in JavaScript - Dmitri Pavlutin
January 28, 2023 - Object destructuring is a JavaScript feature to extract properties from objects and bind them to variables.
🌐
DEV Community
dev.to › coderjay06 › how-to-destructure-nested-javascript-objects-1dcl
How to Destructure Nested JavaScript Objects - DEV Community
November 13, 2021 - Here we have our employees object nested several levels deep. If we need to access an employee’s info we can destructure as many levels as it takes to get to our employee object’s properties.
🌐
Wes Bos
wesbos.com › destructuring-objects
A Dead Simple intro to Destructuring JavaScript Objects - Wes Bos
November 15, 2016 - Let's take a look at what problem JavaScript destructuring really solves. Sometimes you need top level variables like so: const person = { first: 'Wes', last: 'Bos', country: 'Canada', city: 'Hamilton', twitter: '@wesbos' }; const first = person.first; const last = person.last; You get the point. You've got this pretty much repetitive code over and over again, where you need to make a variable from something that is inside of an object or inside of an array.
Find elsewhere
🌐
Daniel Abrahamberg
abrahamberg.com › home › javascript destructuring nested object and array
JavaScript destructuring nested object and array
December 2, 2023 - In this example, we’re Javascript destructuring the nestedData object and using nested array and object destructuring patterns to extract the street property of the fifth address in the addresses array. The value is then assigned to a new constant variable called fifthAddressStreet.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Operators › Destructuring_assignment
Destructuring - JavaScript | MDN
For array destructuring, it collects remaining elements of the iterable into a new array called rest (or any name you give it). For object destructuring, it copies all enumerable own properties of the object that are not already picked off by the destructuring pattern into a new object called rest.
🌐
freeCodeCamp
freecodecamp.org › news › javascript-object-destructuring-spread-operator-rest-parameter
JavaScript Object Destructuring, Spread Syntax, and the Rest Parameter – A Practical Guide
February 8, 2021 - So, how do we extract values from more than one object property? Simple – we keep adding the object keys inside the {} with commas separating them. In the example below, we destructure both the name and age properties from the user object.
🌐
Greenroots
blog.greenroots.info › javascript-object-destructuring-usages-you-must-know
JavaScript object destructuring usages you must know
May 6, 2025 - You don't need to take the entire object as an argument and pick the required property values. You pass the values directly as function arguments and use them inside. ... There is one more usage of object destructuring with function.
🌐
Tsmx
tsmx.net › destructuring-of-nested-object-properties-in-javascript
Destructuring nested object properties in JavaScript – tsmx
Let’s assume you have the following JavaScript object. const person = { name: 'John', address: { country: 'USA', city: 'New York', details: { street: 'Broadway', number: 3155 } } } To only access the name property of the object when its passed over, you can use standard destructuring like so…
🌐
JavaScript in Plain English
javascript.plainenglish.io › nested-destructuring-in-javascript-3fe186b1d34e
Nested Object Destructuring in JavaScript | JavaScript in Plain English
May 19, 2022 - We want to access the second object so just like when we are destructuring flat arrays we can use a comma to skip an element. We then use curly braces because we are inside of an object and the name of the property we want to pick out from the object. Just like when we…
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-object-destructuring-in-js
JavaScript - Object Destructuring in JS - GeeksforGeeks
const person = { name: "Alice", age: 25, location: "New York" }; // Destructuring the properties into variables const { name, age } = person; console.log(name); console.log(age); ... We can also rename variables while object destructuring.
Published   November 30, 2024
🌐
DEV Community
dev.to › am20dipi › a-guide-to-object-destructuring-in-javascript-4a4l
A Guide to Object Destructuring in JavaScript - DEV Community
August 6, 2021 - The "person" object has a property called "previousJob" and "previousJob" has two (2) properties, "title" and "location". This is nesting: we have an object inside another object. To access a property of a nested object, we can of course use object destructuring.
🌐
JavaScript Tutorial
javascripttutorial.net › home › javascript tutorial › javascript object destructuring
JavaScript Object Destructuring
December 17, 2023 - If you want to learn how to destructure an array, you can check out the array destructuring tutorial. Suppose you have a person object with two properties: firstName and lastName. let person = { firstName: 'John', lastName: 'Doe' };Code language: JavaScript (javascript)
🌐
TutorialsPoint
tutorialspoint.com › javascript › javascript_nested_destructuring.htm
JavaScript - Nested Destructuring
The Nested Destructuring in JavaScript allows us to extract data from nested objects and arrays. An object (or array) can contain another object (or array) inside itself, known as a nested object (or array).
🌐
ITNEXT
itnext.io › using-es6-to-destructure-nested-objects-in-javascript-avoid-undefined-errors-that-break-your-code-612ae67913e9
Using ES6 To Destructure Deeply Nested Objects in JavaScript & Avoid Undefined Errors that Break Your Code | by Paige Niedringhaus | ITNEXT
May 27, 2019 - Using ES6 To Destructure Deeply Nested Objects in JavaScript & Avoid Undefined Errors that Break Your Code Because Airbnb’s ESLint is Merciless in React Introduction In case this is your first time …