Skip to content

Instantly share code, notes, and snippets.

@droidjahangir
Created September 15, 2021 05:23
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 droidjahangir/70598f0d52a48ae6ce058ededa12503a to your computer and use it in GitHub Desktop.
Save droidjahangir/70598f0d52a48ae6ce058ededa12503a to your computer and use it in GitHub Desktop.
const hobbies = ['Sports', 'Cooking'];
const activeHobbies = ['Hiking'];
activeHobbies.push(...hobbies);
// const activeHobbies = ['Hiking', ...hobbies];
const person = {
name: 'Max',
age: 30,
};
// We're copying the pointer/reference of the person object in memory to this copiedPerson constant
const copiedPersonShallow = person;
// To create a real copy
const copiedPersonDeep = { ...person };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment