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.
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
@@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
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).
WATCH NEXT: Javascript Interview Questions and Answers - Dominate Your Next Interview - th-cam.com/video/wnYKH2dO620/w-d-xo.htmlsi=5DfbGEfhXWiiv0a_
Good lesson, thx
You are welcome!
Super helpful, thanks!
You're welcome!
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.
Yeap, you are totally right.
отличное видео спасибою
Great video. But what about structuredClone method?
You can certainly use it if you don't need to support older browsers.
Another great tutorial! Thnxz!
My pleasure!
You are good man!
Thank you
❤️❤️❤️
Before this usefull tutorial, I`ve known only variants how to implement deep clone array.
How to clone function as property in an object ?
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
how about structuredClone()
Sure you can use that if you don't need to support older browsers like IE for example
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!
I would love to collaborate with them but they both didn't answer my emails.
@@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
@@ylsv I will try again as it costs me nothing. Thanks!
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!!
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).