Some built-in objects have properties hidden in a closure(namespace), such as Date/String objects. So if you clone an object by just recursively copying all the enumerable or non-enumerable variables/methods into an empty object, it won't work, even including its prototype. It is impossible to detect the private variables(closure) in an object in Javascript.
A lot of people (including me) who try to write the deep clone method will finally find it almost impossible:
@reference_1_stackoverflow
No comments:
Post a Comment