I surely will use the recursion approach too. However, typeof is sloppy in terms of differentiating between array and object. In order to truly check for object type, I will go with plain old trick below:
Cool. I missed that part. Thanks for the solution.
I was just giving some information about how can we make such a function to deep copying with help of recursion. So, there might be some more improvements that can be implemented to make it handle every case.
I surely will use the recursion approach too. However,
typeof
is sloppy in terms of differentiating between array and object. In order to truly check forobject
type, I will go with plain old trick below:Cool. I missed that part. Thanks for the solution.
I was just giving some information about how can we make such a function to deep copying with help of recursion. So, there might be some more improvements that can be implemented to make it handle every case.
But Great Insight!
That's a good point.