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

Поділитися
Вставка
  • Опубліковано 5 жов 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)

  • @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.

  • @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!!!

  • @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

  • @praveenbehera1307
    @praveenbehera1307 Рік тому +1

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

  • @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.

  • @aritradas8606
    @aritradas8606 Рік тому +1

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

  • @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

  • @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....☺

  • @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

  • @razasaleem1154
    @razasaleem1154 Рік тому +1

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

  • @vartikaJoshi-en4he
    @vartikaJoshi-en4he 10 місяців тому +1

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

  • @inspiredomkar1239
    @inspiredomkar1239 2 місяці тому

    Insightful video.Everything got crystal clear thank you.!

  • @abhishekrai215
    @abhishekrai215 Рік тому

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

  • @ermahesh2009
    @ermahesh2009 2 роки тому

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

  • @aakash261
    @aakash261 2 роки тому

    your explanation is easy and awesome, my concept got cleared thank you 👍

  • @mr.wazirgaming2696
    @mr.wazirgaming2696 2 роки тому +1

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

  • @amanverma7977
    @amanverma7977 Рік тому +1

    Thank you so much, simplest explanation

  • @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.

  • @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

  • @tejusgroup6695
    @tejusgroup6695 2 роки тому

    concept is clear sir.. thanks for teaching in a simple way.. Happy coding

  • @sufigaming135
    @sufigaming135 Місяць тому

    brother good teaching doubt clear thank u

  • @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...!

  • @surajprakash2760
    @surajprakash2760 Рік тому

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

  • @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

  • @mohitkumar-zd9pv
    @mohitkumar-zd9pv Рік тому +2

    made it so easy, keep up...

  • @UdayPawarUdi
    @UdayPawarUdi Рік тому

    Very nice teaching. Very good way of explanation.

  • @akashtiwari3358
    @akashtiwari3358 2 роки тому +2

    what a explaination👏gudluck brother

  • @imnawasthi
    @imnawasthi Рік тому +1

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

  • @mdajaroddin2303
    @mdajaroddin2303 11 місяців тому

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

  • @shawonbiswas9082
    @shawonbiswas9082 2 роки тому

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

  • @ScriptyVijay
    @ScriptyVijay Рік тому

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

  • @rajendra_K_
    @rajendra_K_ Рік тому

    @Anil thank you very much explaining complex topics in a such a easy way :)

  • @TarunKumar-ds7ti
    @TarunKumar-ds7ti Рік тому +1

    thanks bro itna deep me batane ke liye

  • @ashutoshshrivastava57
    @ashutoshshrivastava57 3 місяці тому

    Very awesome explanation sir.

  • @shailenderjaiswal1685
    @shailenderjaiswal1685 Рік тому +1

    sir you were using spread operator not destructuring in shallow copy

  • @VISHNUKUMAR-eg1he
    @VISHNUKUMAR-eg1he 7 місяців тому

    Really nice explanation step by step ❤

  • @mahakalwonder7937
    @mahakalwonder7937 5 місяців тому

    Great explanation thanks.

  • @AshrafAli_SoftwareDev
    @AshrafAli_SoftwareDev 4 місяці тому

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

  • @emanrazzak1072
    @emanrazzak1072 2 роки тому

    Alhamdulillah all confusion cleared now

  • @ajitrana3158
    @ajitrana3158 Рік тому

    Thnx sir aapke batane ka trika bhut ache h I like it

  • @rutvikbhatt6654
    @rutvikbhatt6654 2 роки тому +2

    Very helpful ☺️ 👍

  • @ashishagrawal8975
    @ashishagrawal8975 2 роки тому

    Your video is helpful for me so can you please make video for Oops in JavaScript...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

  • @awaisamin-p1x
    @awaisamin-p1x Рік тому

    very impressive explanation . thanku sir

  • @SonuKumar-uq2rb
    @SonuKumar-uq2rb Рік тому

    very well explained thanks

  • @Nitesh_Arya77
    @Nitesh_Arya77 11 місяців тому

    Great explanation sir

  • @rahilkhan6551
    @rahilkhan6551 2 роки тому +1

    great video
    define in well way

  • @prajwalnayak214
    @prajwalnayak214 Рік тому

    Best explanation ever made!

  • @Code_with_random
    @Code_with_random Рік тому

    Good explanation easy to understand

  • @sugandhaparasher8861
    @sugandhaparasher8861 Рік тому

    Very well Explained. thank you .

  • @gulrezeqbal3048
    @gulrezeqbal3048 Рік тому

    one of the great explanation

  • @tusharshrivastava7184
    @tusharshrivastava7184 2 роки тому +1

    Please make video of oops in js

  • @vikkaguru7712
    @vikkaguru7712 2 роки тому +1

    bahut khub bhai ji

  • @fatimaiqra2169
    @fatimaiqra2169 Місяць тому

    Thank you so much

  • @beautyofworld1700
    @beautyofworld1700 Рік тому

    keet it up. best explaination.

  • @techrify1146
    @techrify1146 6 місяців тому

    Nice Explaination

  • @sumantripathii431
    @sumantripathii431 2 роки тому +1

    Nyc clear concept

  • @subhamdudheria9523
    @subhamdudheria9523 2 роки тому +2

    Does the same thing goes with array?

  • @mzohaib27
    @mzohaib27 11 місяців тому

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

  • @ajaychimanpure7010
    @ajaychimanpure7010 2 роки тому

    Very well Explained Anil..!!☺️

  • @ashitoshpatil8678
    @ashitoshpatil8678 Рік тому

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

  • @amittiwari4163
    @amittiwari4163 2 роки тому +2

    Very nice sir but pls share this with us

  • @PankajSingh-zq7xn
    @PankajSingh-zq7xn 26 днів тому

    Useful video ❤

  • @mayurchaudhari4239
    @mayurchaudhari4239 8 місяців тому

    Well done master khup mast

  • @BeastUn
    @BeastUn Рік тому

    thANK U FOR THIS GREAT EXPLANATION

  • @jagdishjena9058
    @jagdishjena9058 2 роки тому

    Keep on making these interview questions.

  • @ehtixhamamjad
    @ehtixhamamjad Рік тому

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

  • @ChetanPednekar
    @ChetanPednekar Рік тому

    Nice example & explanation Anil. Thanks!
    Just wanted to confirm if we can call (...) three dots as a 'spread' operator instead of 'de-structuring' ?

  • @vishalrindhe4025
    @vishalrindhe4025 Рік тому

    Best ever explanation 🤩

  • @ramzanchaudhry3999
    @ramzanchaudhry3999 Рік тому

    amazing bro . well explained 👍

  • @Rajeevkumar-sx3er
    @Rajeevkumar-sx3er Рік тому

    Really good video bro

  • @sanjanaprajapati9707
    @sanjanaprajapati9707 Рік тому

    Really good explanation 👍

  • @AhmadAli-no6bw
    @AhmadAli-no6bw 2 роки тому

    You are the best.

  • @lokeshawasthi6640
    @lokeshawasthi6640 2 місяці тому

    amazing class

  • @prashantmestry699
    @prashantmestry699 2 роки тому

    nice explanation on this topic.

  • @rehanhaq3564
    @rehanhaq3564 2 роки тому +1

    This keyword or event loop

  • @InspiringPositiveQuotes1196
    @InspiringPositiveQuotes1196 8 місяців тому

    helpful brother

  • @fatimaiqra2169
    @fatimaiqra2169 Місяць тому

    Thanks

  • @hackerwhite7957
    @hackerwhite7957 2 роки тому +1

    Helpful video

  • @abhishektaur
    @abhishektaur Рік тому

    good explation

  • @SonuKumar-uq2rb
    @SonuKumar-uq2rb Рік тому

    very good keep it up bro

  • @suyashsrivastava3671
    @suyashsrivastava3671 8 днів тому

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

  • @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???

  • @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 2 місяці тому

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

  • @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

  • @jagdishjena9058
    @jagdishjena9058 2 роки тому

    Thank you so much sir.

  • @nikleshniks
    @nikleshniks 2 роки тому

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

  • @millwoodfurnace2739
    @millwoodfurnace2739 Рік тому

    Nice Explanation!!!!!

  • @mohitkumar-zd9pv
    @mohitkumar-zd9pv Рік тому

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

  • @physicsazamgarh5731
    @physicsazamgarh5731 Рік тому

    the best🙏🙏🙏🙏🙏

  • @misbahsiddiqui9365
    @misbahsiddiqui9365 11 місяців тому

    superb

  • @subhadeepghosh2813
    @subhadeepghosh2813 Рік тому

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

  • @vaibhavsingh8644
    @vaibhavsingh8644 5 місяців тому

    ❤❤❤❤useful

  • @ravi_pk
    @ravi_pk 2 роки тому

    Nice sir

  • @sourabhgera1364
    @sourabhgera1364 Рік тому

    Definition Shallow copy and deep copy ?

  • @tusharsamanta7028
    @tusharsamanta7028 2 роки тому

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

  • @sakshampethkar8970
    @sakshampethkar8970 2 роки тому

    Javascript symbols like NaN bhi nhi honge deep copy

  • @deepakbehera3357
    @deepakbehera3357 2 роки тому

    Repository name plz

  • @talibhusain3335
    @talibhusain3335 Рік тому

    Wow💐