Skip to content

Instantly share code, notes, and snippets.

@nmaxcom
Created November 1, 2022 11:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nmaxcom/76f97f51b23c8b535520afa580db1205 to your computer and use it in GitHub Desktop.
Save nmaxcom/76f97f51b23c8b535520afa580db1205 to your computer and use it in GitHub Desktop.
More concise way of pushing only a few obj keys into an array
const bigObj = {
title: "BLabla",
text: "sda nasd asld asdjas dsa dlajsd sdjdalsdj dasjd asdkj",
bu: "kjjk",
bla: 32,
image: "https://www.blup.com/blabla.png",
};
let arr = [];
const { title, text, image } = bigObj;
const reducedObj = { title, text, image };
arr.push(reducedObj);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment