Can someone explain the differences between angular.copy() and JSON.parse(JSON.stringify())? Are there any? What you will recommend to use? Is angular.fromJson(angular.toJson()) the same as JSON.parse(JSON.stringify())?
Just to mention, I've read How do I correctly clone a JavaScript object? for JSON.parse(JSON.stringify()) and angular.copy() reference for angular.copy().
Join the Stack Overflow Community
Stack Overflow is a community of 6.9 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up
Join them; it only takes a minute:
|
|||
|
What
|
|||
|
I can very specifically answer your question by pointing out they treat
And more generally I would prefer angular.copy:
That being said, do they treat more esoteric data, such as functions, the same way? I can't answer this off the top of my head but I would research (or wait for another answer) before deciding. |
|||||||||||||||||
|