Javascript Clone Object | Deep copy object Javascript

แชร์
ฝัง
  • เผยแพร่เมื่อ 28 พ.ย. 2024

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

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

    WATCH NEXT: Javascript Interview Questions and Answers - Dominate Your Next Interview - th-cam.com/video/wnYKH2dO620/w-d-xo.htmlsi=5DfbGEfhXWiiv0a_

  • @AlexAlex-nh5mc
    @AlexAlex-nh5mc 2 ปีที่แล้ว +2

    Good lesson, thx

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

    Super helpful, thanks!

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

    great work but maybe it does not work with Date properties))) you should to add "... || input instanceof Date" to the condition of the first if statements.

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

    отличное видео спасибою

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

    Great video. But what about structuredClone method?

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

      You can certainly use it if you don't need to support older browsers.

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

    Another great tutorial! Thnxz!

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

    You are good man!

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

    ❤️❤️❤️

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

    Before this usefull tutorial, I`ve known only variants how to implement deep clone array.
    How to clone function as property in an object ?

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

      For example spread operator can copy functions.
      But the most correct answer is that you should not have functions inside your object because objects are representation of the data. Also it is easier to support plain objects without prototypes, functions, etc

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

    how about structuredClone()

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

      Sure you can use that if you don't need to support older browsers like IE for example

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

    So little views and comments for such a cool channel and useful information. Maybe collaborate with Brad Traversy or Kyle Cook?)
    Thank you for vids!

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

      I would love to collaborate with them but they both didn't answer my emails.

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

      @@MonsterlessonsAcademy That's strange, Brad promoted Kyle. Why wouldn't they support more good content... Try twitter, devs seem to be more active there, but u probably know it already

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

      @@ylsv I will try again as it costs me nothing. Thanks!

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

    what about circular deps?
    let newA = {
    a: 1,
    b: [1, 2],
    c: [1, [2, 3]],
    d: {
    d1: 1,
    d2: [1, 2],
    d3: {}
    }
    };
    newA.d.d3 = newA.d;
    let deep = deepClone(newA)
    stackoverflow!!

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

      Hi you are totally right it will break as we don't check circular deps. But I don't think that having such things in a real project is a good idea and is needed (can't imagine such case).