Skip to content

Instantly share code, notes, and snippets.

@ashutoshkrris
Created April 6, 2022 04:23
Show Gist options
  • Select an option

  • Save ashutoshkrris/4ca82f420d3b7cc29233a6ab0a3e0191 to your computer and use it in GitHub Desktop.

Select an option

Save ashutoshkrris/4ca82f420d3b7cc29233a6ab0a3e0191 to your computer and use it in GitHub Desktop.
const postData = [1, 'Getting Started With Rich', 'Ashutosh Krishna'];
const [postId, postTitle, postAuthor] = postData;
console.log(postId, postTitle, postAuthor);
// With Objects
const anotherPostData = {
anotherPostId: 1,
anotherPostTitle: 'Getting Started With Rich',
anotherPostAuthor: 'Ashutosh Krishna'
};
const {anotherPostId, anotherPostTitle, anotherPostAuthor} = anotherPostData;
console.log(anotherPostId, anotherPostTitle, anotherPostAuthor);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment