Issue
I want to have a shallow copy of an object but preserve its prototype. angular.extend
seems to lose prototype when extending object. How can I extend an object so that the new object has the same prototype as original?
Solution
It seems the only way to do so is to additionally use setPrototypeOf
like this:
var copy = angular.extend(original);
Object.setPrototypeOf(copy, original.getPrototypeOf(original))
Also, extend
drops getters
and setters
defined through Object.defineProperty
on an original
.
Answered By - Max Koretskyi
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.