Skip to content

Instantly share code, notes, and snippets.

@lumosmind
Created May 11, 2019 20:03
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 lumosmind/666d43a03485b1bf1e899839c27dd352 to your computer and use it in GitHub Desktop.
Save lumosmind/666d43a03485b1bf1e899839c27dd352 to your computer and use it in GitHub Desktop.
// o1 nesnesini object literal olarak tanımla
const o1 = {
w: 'lorem ipsum',
x: 42,
y: 3.14,
g: function () { },
h: function () { }
};
// o1 nesnesini kopyalayıp o2 nesnesi oluştur
const o2 = Object.assign({}, o1);
console.log(o1); // {w: "lorem ipsum", x: 42, y: 3.14, g: ƒ, h: ƒ}
console.log(o2); // {w: "lorem ipsum", x: 42, y: 3.14, g: ƒ, h: ƒ}
// o2 nesnesinin özelliklerini değiştirip kullanıma hazırla
o2.w = 'dolor sit';
o2.x = 45;
o2.y = 2.71;
console.log(o2); //{w: "dolor sit", x: 45, y: 2.71, g: ƒ, h: ƒ}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment