JavaScript Object Clone | Deep and Shallow Copy in Hindi | Interview Questions

แชร์
ฝัง
  • เผยแพร่เมื่อ 28 ก.ย. 2024
  • In this javascript object deep copy and shallow copy tutorial, we learn to clone object in javascript and we learn about deep copy of object and shallow copy of object . this video made by anil Sidhu in Hindi language
    Steps
    what is object clone in hindi
    why we need object clone
    type of object clone
    Example
    deep copy of object
    shallow copy of object
    Interview Questions
    React js Latest Playlist in hindi : • React tutorial for beg...
    inst id: @code.steps

ความคิดเห็น • 136

  • @Satyamsingh-fw4mh
    @Satyamsingh-fw4mh ปีที่แล้ว +21

    1. Objects are copied by reference and variables by value.
    2. To copy objects by value:
    ==>Object.Assign({}, obj)
    ==>{...obj}
    3. The above method is shallow copy. It copies only top-level fields.
    4. To copy nested objects, deep copy comes into picture.
    ==>JSON.parse(JSON.stringyfy(obj));
    5. But the above doesn’t copy functions and dates. So, loadash is used.
    ==>_.cloneDeep(obj)

  • @rajnisrivastav1599
    @rajnisrivastav1599 2 ปีที่แล้ว +5

    The best explanation one could have asked for. I just have one question what if the Interviewer ask which is better Deep copy or shallow copy?

    • @codestepbystep
      @codestepbystep  2 ปีที่แล้ว +4

      They can not ask which one is better. We choose copy type over requirement

  • @ermahesh2009
    @ermahesh2009 ปีที่แล้ว

    Bhai itte aache se samjata hai practice ki jarorat bhi nahi padi sidda ghus gaya dimag mai.

  • @supergameras2936
    @supergameras2936 5 หลายเดือนก่อน

    You are great sir your videos very helpful and You always talk about the important things, you don't prolong the conversation. Thanks

  • @aakashujjainwal7147
    @aakashujjainwal7147 ปีที่แล้ว

    thank you bro it was really helpful ..mere bhot sare confusion dur ho gye ....keep learning & keep teaching us ...best of luck bro

  • @awaisahmad8935
    @awaisahmad8935 2 หลายเดือนก่อน

    Hi tutor your Urdu accent is unique and guaranteed quality concept also makes your channel awesome. speak English where necessary because urdu is my mother tongue easy to understand.

  • @dhananjayrakshe7655
    @dhananjayrakshe7655 ปีที่แล้ว

    I saw lots of video but i also get confusion in shallow and deep copy but in this video i understand total about that. Nice work buddy...!

  • @akashtiwari3358
    @akashtiwari3358 2 ปีที่แล้ว +2

    what a explaination👏gudluck brother

  • @mr.wazirgaming2696
    @mr.wazirgaming2696 2 ปีที่แล้ว +1

    It's so cleared now ❤️👍 about objects. Thanks 😊

  • @shawonbiswas9082
    @shawonbiswas9082 2 ปีที่แล้ว

    I am soo happy with your concept 😍 just e bolna chatahu aiiisa bahut sara interview question chaiye jojo question pucha jatahe

  • @shailenderjaiswal1685
    @shailenderjaiswal1685 ปีที่แล้ว +1

    sir you were using spread operator not destructuring in shallow copy

  • @ashutoshshrivastava57
    @ashutoshshrivastava57 3 หลายเดือนก่อน

    Very awesome explanation sir.

  • @ashitoshpatil8678
    @ashitoshpatil8678 ปีที่แล้ว

    bind call apply use nhi kar sakte kya fir methods ke liye jo bhi obj mai present
    hai

  • @UdayPawarUdi
    @UdayPawarUdi ปีที่แล้ว

    Very nice teaching. Very good way of explanation.

  • @vikkaguru7712
    @vikkaguru7712 2 ปีที่แล้ว +1

    bahut khub bhai ji

  • @surajprakash2760
    @surajprakash2760 ปีที่แล้ว

    Thank you so much , you explain us in very simplest way. 😊

  • @Nitesh_Arya77
    @Nitesh_Arya77 11 หลายเดือนก่อน

    Great explanation sir

  • @Code_with_random
    @Code_with_random ปีที่แล้ว

    Good explanation easy to understand

  • @mdajaroddin2303
    @mdajaroddin2303 11 หลายเดือนก่อน

    Awesome explaining sir shallow copy and deep copy.its very helpfull video thank you so much

  • @amittiwari4163
    @amittiwari4163 2 ปีที่แล้ว +2

    Very nice sir but pls share this with us

  • @Rajeevkumar-sx3er
    @Rajeevkumar-sx3er ปีที่แล้ว

    Really good video bro

  • @sugandhaparasher8861
    @sugandhaparasher8861 ปีที่แล้ว

    Very well Explained. thank you .

  • @ajaychimanpure7010
    @ajaychimanpure7010 2 ปีที่แล้ว

    Very well Explained Anil..!!☺️

  • @fatimaiqra2169
    @fatimaiqra2169 29 วันที่ผ่านมา

    Thank you so much

  • @pritamkeshri8389
    @pritamkeshri8389 ปีที่แล้ว

    Nice explanation

  • @mzohaib27
    @mzohaib27 10 หลายเดือนก่อน

    v nice sir.... amazing.... thank you...

  • @rehanhaq3564
    @rehanhaq3564 2 ปีที่แล้ว +1

    This keyword or event loop

  • @InspiringPositiveQuotes1196
    @InspiringPositiveQuotes1196 8 หลายเดือนก่อน

    helpful brother

  • @sanjanaprajapati9707
    @sanjanaprajapati9707 ปีที่แล้ว

    Really good explanation 👍

  • @azanraja5089
    @azanraja5089 2 หลายเดือนก่อน

    if we put an console in between like:-
    let obj = {
    name: "peter",
    };
    console.log(obj);
    let user = obj;
    user.name = "hello";
    console.log(obj);
    than the result is
    peter
    hello
    why it already update the obj value than why the peter prints
    why the hello not prints 2 times

    • @Nishantsingh-ys5cm
      @Nishantsingh-ys5cm หลายเดือนก่อน

      bro the output is correct because you console.log('obj') before copy it to the user.

  • @kamaal2110
    @kamaal2110 2 ปีที่แล้ว

    so what then if we have a object and it properties with function and we have to copy it by `let obj2 = Object.assign({}, obj1);` and modified one property value in obj2 so it will be shallow copy or deep copy???

  • @jagdishjena9058
    @jagdishjena9058 2 ปีที่แล้ว

    Thank you so much sir.

  • @mohitkumar-zd9pv
    @mohitkumar-zd9pv ปีที่แล้ว

    What is the difference between deep copy/shallow copy and deep cloning/shallow cloning, are they same?

  • @talibhusain3335
    @talibhusain3335 ปีที่แล้ว

    Wow💐

  • @sakshampethkar8970
    @sakshampethkar8970 2 ปีที่แล้ว

    Javascript symbols like NaN bhi nhi honge deep copy

  • @thersh4882
    @thersh4882 4 หลายเดือนก่อน

    Wowww

  • @nikleshniks
    @nikleshniks 2 ปีที่แล้ว

    😃Like to bantaa hai Boss😃
    Really, amazing & to much concepts have been cleared

  • @Growfacts
    @Growfacts 2 ปีที่แล้ว

    Great❤️❤️❤️

  • @abdulqayyum7462
    @abdulqayyum7462 5 หลายเดือนก่อน

    Visibal issues hy

  • @rahulthakur-rb6xz
    @rahulthakur-rb6xz 2 ปีที่แล้ว +1

    Thank you aap mat boliye balki hame bolne dijiye
    Thank you

  • @pujamohanty8825
    @pujamohanty8825 2 ปีที่แล้ว +1

    👍

  • @pranavb9768
    @pranavb9768 9 หลายเดือนก่อน

    lodesh 🤌

  • @travel2react567
    @travel2react567 2 ปีที่แล้ว +15

    Before watching this video, I was having a lot of confusion about deep copy and Shallow copy but now it's crystal clear. Thanks a lot. Your teaching style is awesome.

  • @sudhirmohanty5971
    @sudhirmohanty5971 2 ปีที่แล้ว +4

    I have a question regarding shallow copy please explain. U told 8:11 that in shallow copy means value of a object is copied not the reference . But when i search in google there i found inside bracket (In Shallow copy, a copy of the original object is stored and only the reference address is finally copied. ).
    please sir clear this to me

  • @zeeshanahmad1675
    @zeeshanahmad1675 2 ปีที่แล้ว +4

    Rather then going to browser console all the time
    Y dont you try { node (name of the JS file) } and press enter
    in your vs code terminal
    it will be more helpful

  • @yashwani8155
    @yashwani8155 ปีที่แล้ว +2

    I don't know how to thank you man!!! I was stuck on a bug for like 24 hours due to this problem....Thanks you loads!!! liked and subscribed!!!

  • @mohitkumar-zd9pv
    @mohitkumar-zd9pv ปีที่แล้ว +2

    made it so easy, keep up...

  • @harshvardhan7718
    @harshvardhan7718 ปีที่แล้ว +1

    Thanks for this video sir. Bt humlog fresher hai to samjhane ke tym thoda sa dhire samjhenge to aur bahetar hoga. Again saying nice video sir keep it up.
    Dhannebad....☺

  • @suyashsrivastava3671
    @suyashsrivastava3671 วันที่ผ่านมา

    structuredClone is a new way to create deep copy in js.

  • @subhamdudheria9523
    @subhamdudheria9523 2 ปีที่แล้ว +2

    Does the same thing goes with array?

  • @rutvikbhatt6654
    @rutvikbhatt6654 2 ปีที่แล้ว +2

    Very helpful ☺️ 👍

  • @imnawasthi
    @imnawasthi ปีที่แล้ว +1

    paji Bht hi sahi explain kita tusi att krti, paji ik question a ki same cheej arrays nal b hundi a ?

  • @tusharshrivastava7184
    @tusharshrivastava7184 2 ปีที่แล้ว +1

    Please make video of oops in js

  • @rahulnath3244
    @rahulnath3244 2 ปีที่แล้ว +1

    Sir opps me video

  • @mosaddikalimaruf2722
    @mosaddikalimaruf2722 ปีที่แล้ว

    You Didn't even give the definition what you have said you'll provide, "Baad me"!

  • @amanverma7977
    @amanverma7977 ปีที่แล้ว +1

    Thank you so much, simplest explanation

  • @sourabhgera1364
    @sourabhgera1364 ปีที่แล้ว

    Definition Shallow copy and deep copy ?

  • @sufigaming135
    @sufigaming135 หลายเดือนก่อน

    brother good teaching doubt clear thank u

  • @TarunKumar-ds7ti
    @TarunKumar-ds7ti ปีที่แล้ว +1

    thanks bro itna deep me batane ke liye

  • @SonuKumar-uq2rb
    @SonuKumar-uq2rb ปีที่แล้ว

    very well explained thanks

  • @mayurchaudhari4239
    @mayurchaudhari4239 8 หลายเดือนก่อน

    Well done master khup mast

  • @subhadeepghosh2813
    @subhadeepghosh2813 ปีที่แล้ว

    maza aa gya🎉🎉🎉🎉🎉❤❤❤❤❤❤❤

  • @beautyofworld1700
    @beautyofworld1700 ปีที่แล้ว

    keet it up. best explaination.

  • @mahakalwonder7937
    @mahakalwonder7937 5 หลายเดือนก่อน

    Great explanation thanks.

  • @deepakbehera3357
    @deepakbehera3357 2 ปีที่แล้ว

    Repository name plz

  • @praveenbehera1307
    @praveenbehera1307 ปีที่แล้ว +1

    Finally!!! I am able to understand Shallow and Deep copy. Thank you

  • @chetanpatil9917
    @chetanpatil9917 ปีที่แล้ว +1

    This is an underrated channel. All these awesome videos should reach to more people.
    Do Like and subscribe this channel

  • @DeepakisDemigod
    @DeepakisDemigod ปีที่แล้ว

    sí, manzana come amigos

  • @aritradas8606
    @aritradas8606 ปีที่แล้ว +1

    Just brilliantly explained. Very apt, systematic and well defined. Removed all my confusions forever!

  • @SonuKumar-uq2rb
    @SonuKumar-uq2rb ปีที่แล้ว

    very good keep it up bro

  • @rahilkhan6551
    @rahilkhan6551 2 ปีที่แล้ว +1

    great video
    define in well way

  • @techrify1146
    @techrify1146 6 หลายเดือนก่อน

    Nice Explaination

  • @PankajSingh-zq7xn
    @PankajSingh-zq7xn 19 วันที่ผ่านมา

    Useful video ❤

  • @hackerwhite7957
    @hackerwhite7957 2 ปีที่แล้ว +1

    Helpful video

  • @ScriptyVijay
    @ScriptyVijay ปีที่แล้ว

    Sir bohot dino bad channel mila bawal hi padha rhe ho app 🙏🏻 1:27

  • @abhishektaur
    @abhishektaur ปีที่แล้ว

    good explation

  • @vartikaJoshi-en4he
    @vartikaJoshi-en4he 9 หลายเดือนก่อน +1

    Amazing explanation..best explanation in TH-cam for this topic .

  • @sumantripathii431
    @sumantripathii431 2 ปีที่แล้ว +1

    Nyc clear concept

  • @physicsazamgarh5731
    @physicsazamgarh5731 ปีที่แล้ว

    the best🙏🙏🙏🙏🙏

  • @taniajebin8437
    @taniajebin8437 ปีที่แล้ว

    Thanks a lot

  • @dilpavittarpalsingh9088
    @dilpavittarpalsingh9088 2 ปีที่แล้ว

    veer code da link provide krdo
    mil nai rea

  • @fatimaiqra2169
    @fatimaiqra2169 หลายเดือนก่อน

    Thanks

  • @vaibhavsingh8644
    @vaibhavsingh8644 5 หลายเดือนก่อน

    ❤❤❤❤useful

  • @ravi_pk
    @ravi_pk 2 ปีที่แล้ว

    Nice sir

  • @misbahsiddiqui9365
    @misbahsiddiqui9365 10 หลายเดือนก่อน

    superb

  • @snehakamble229
    @snehakamble229 4 หลายเดือนก่อน

    very well explained. thank you

    • @codestepbystep
      @codestepbystep  4 หลายเดือนก่อน

      Glad it was helpful!

  • @razasaleem1154
    @razasaleem1154 ปีที่แล้ว +1

    Just preparing for an interview and it helped me a lot, thanks man ♥️

  • @inspiredomkar1239
    @inspiredomkar1239 หลายเดือนก่อน

    Insightful video.Everything got crystal clear thank you.!

  • @ehtixhamamjad
    @ehtixhamamjad ปีที่แล้ว

    please explain Array.prototype.slice & JSON.parse(JSON.stringify(obj))

  • @SajithaKSoman
    @SajithaKSoman 5 หลายเดือนก่อน

    Thank you sir . thank you .After a long time , I understand the concept of deep copy and shallow copy from this video.

  • @priyeshjammula854
    @priyeshjammula854 ปีที่แล้ว

    How can you say solution is not available in javascript Even lodash developers have implemented using javascript only, just that they are providing it as a package. That's misleading

  • @VinayTandale
    @VinayTandale ปีที่แล้ว

    sir destructing method can be used? let user=[obj] and then we can change both values? is this feasible to use

    • @codestepbystep
      @codestepbystep  ปีที่แล้ว +1

      destruction will do only shallow copy not deep

    • @VinayTandale
      @VinayTandale ปีที่แล้ว

      @@codestepbystep it helped me for todays interview sir....😊😊😊i have watched complete tutorial of mern and it helped me a lot....i hade made notes of your all videos....and while making projects i use it a lot....Sir websockets and tensorflow js if possible...❤️❤️❤️it helped me a lot

  • @ashishagrawal8975
    @ashishagrawal8975 2 ปีที่แล้ว

    Your video is helpful for me so can you please make video for Oops in JavaScript...thank you

  • @AshrafAli_SoftwareDev
    @AshrafAli_SoftwareDev 4 หลายเดือนก่อน

    No scope to dislike the video. Nice explanation 10/10

  • @tusharsamanta7028
    @tusharsamanta7028 2 ปีที่แล้ว

    Sir, please change your code editor, letter s not visible!!!

  • @awaisamin-p1x
    @awaisamin-p1x 11 หลายเดือนก่อน

    very impressive explanation . thanku sir

  • @lokeshawasthi6640
    @lokeshawasthi6640 2 หลายเดือนก่อน

    amazing class

  • @VISHNUKUMAR-eg1he
    @VISHNUKUMAR-eg1he 7 หลายเดือนก่อน

    Really nice explanation step by step ❤

  • @emanrazzak1072
    @emanrazzak1072 2 ปีที่แล้ว

    Alhamdulillah all confusion cleared now

  • @abhishekrai215
    @abhishekrai215 ปีที่แล้ว

    now cristal clear about deep and shallow thankyou so much bhaiya g