Skip to content

Instantly share code, notes, and snippets.

@senpl
Last active December 1, 2022 11:08
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 senpl/10d030ae0b8cf9444c78e2c014b34ef9 to your computer and use it in GitHub Desktop.
Save senpl/10d030ae0b8cf9444c78e2c014b34ef9 to your computer and use it in GitHub Desktop.
Kontruktor , kopiowanie obiektów i konstruktor kopiujący.
Napisz KlasaA i w niej poleA i poleB
Napisz w niej metodę kopiuj która skopiuje do obiektu poleA i poleB.
Stwórzmy obiektA który będzie klasy KlasaA
Ustawmy mu poleA i poleB.
Przypiszmy obiektB do obiektA
Zmieńmy w obiektA poleA
Wypiszmy z obiektB poleA.
//Jak zrobić, żeby zmiany w obiekcieA nie zmieniały danych w obiektB???
import structuredClone from '@ungap/structured-clone'; (https://stackoverflow.com/questions/122102/what-is-the-most-efficient-way-to-deep-clone-an-object-in-javascript)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment