Skip to main content

Command Palette

Search for a command to run...

Destructuring from nested object and array

Published
โ€ข1 min readโ€ขView as Markdown
const response = {
  msg: "success",
  tags: ["programming", "javascript", "computer"],
  body: {
    count: 5,
    data: ["File 1", "File 2"],
  },
};

const {
  body: {
    data: [file1],
  },
} = response;

console.log(file1); // "File 1"

Thanks for reading ๐Ÿ’™
Follow for daily posts.
Instagram โ— Twitter โ— Facebook

Micro-Learning โ— Web Development โ— Javascript โ— MERN stack โ— Javascript
codedrops.tech

More from this blog

Codedrops.tech

49 posts