Object.assign() Method : Object Oriented Programming in JavaScript Series - Part 7

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

Very well explained! No nonsense and just straight to the point. Thank you sir!

dragonniteIV
Автор

making javascript easy.
learning by examples approach instead of raw theory makes is far better.
excellent content.

shivamsa
Автор

Thanks a lot for this wonderful series.

HakanGalip
Автор

I spend more time in your channel and i suggest to all my colleague about your channel...Thanks man...

velmurugan.personel
Автор

Great tutorials! Thank you so much!!!!

artemipatev
Автор

Hey genius, I implement it, Its work fine, Thanks for sharing the videoes.

abhiabhang
Автор

Hey so instead of Toyota you should give the break() method to Ford

joshrochon
Автор

till this video I found the tutorials quite in-depth and easy to understand. Thanks for all your effort and time.
do you have any html5 and reactjs tutorial ?

swetlinasatpathy
Автор

Hi, first of all, I am very thankful for your tutorials, but I am little bit confused about shallow copy explanation. As I know, shallow means not copy of object, it means sharing same local memory and has same reference, so if you change one of them object, other one will be affected. But if you copy object with Object.assign and then you add new method or property to object, the other object will not be affected.
It is like Deep Copy, isn't it?

oonurgulay
Автор

Didn't you forget a return statement in the last function?

yadusolparterre
Автор

4:00, actually Object.assign() doesnt make the shallow copy, instead makes the deep copy with below exception, please check this MDN example;
(If the source value is a reference to an object, it only copies the reference value.)

let obj1 = { a: 0, b: { c: 0}};

let obj2 = Object.assign({}, obj1);
// { "a": 0, "b": { "c": 0}}

obj1.a = 1;
// { "a": 1, "b": { "c": 0}}
// { "a": 0, "b": { "c": 0}}

obj2.a = 2;
// { "a": 1, "b": { "c": 0}}
// { "a": 2, "b": { "c": 0}}

obj2.b.c = 3;
// { "a": 1, "b": { "c": 3}}
// { "a": 2, "b": { "c": 3}}

baturalkan
Автор

Hello, you said that prototype methods don't get copied but I tried the below code and type() method is in both objects, vitz and toyota.
Why is that so? It should not be present in vitz object, right?

let toyota = {
  drive() {
    return 'driving toyota';
  }
};

toyota.prototype = {
  type() {
    return 'Sedan';
  }
}

let vitz = Object.assign({}, toyota);
console.dir(vitz);
console.dir(toyota);

Atif
Автор

Is it a good practice to use Object.assign method in constructor?

mykolavoinikov
Автор

Can u pls exaplain shallow and deep copy in little detail?

jainshilpi
Автор

I thought in objects it needed to be drive: function(){},

whome
Автор

check this out..
object.assign( [ ], obj ). Magic :). Not a shallow copy right? Or am i just writing rubbish?

martinbozinovski
join shbcf.ru