When should I prefer a clone over an reference in javascript?
at the moment I'm writing a small app and came to the point, where I
thought it would be clever to clone an object, instead of using a
reference.
The reason I'm doing this is, because I'm collecting objects in a list.
Later I will only work with this list, because it's part of a model. The
reference isn't something I need and I want to avoid having references to
outside objects in the list, because I don't want someone to build a
construct, where the model can be changed from an inconsiderate place in
their code. (The integrity of the information in the model is very
important.)
Additional I thought I will get a better performance out of it, when I
don't use references.
So my overall question still is: When should I prefer a clone over an
reference in javascript?
Thanks!
No comments:
Post a Comment