I'm using the webgl framework three.js.
Most of the classes can be "cloned" via a
Wikipedia seems to be very strict when it defines "cloning".
In computer science, cloning refers to the making of an exact copy of an object...
However, i've encountered something like this:
const myClass = new Class() myClass.foo = 'foo' myClassClone = myClass.clone() myClassClone.foo === myClass.foo //true
^ this is what i expect to see out of a "clone".
The documentation for the library does not seem to be consistent though:
Returns a clone of this object and optionally all descendants.
Return a new material with the same parameters as this material.
I'm struggling with the second one because i've encountered something like this
myClass = new Class() myClass.foo = 'foo' myClass.bar = 'bar' myClone = myClass.clone() myClone.foo === myClass.foo //true myClone.bar === myClass.bar //false
Depending on what foo and bar are, my clone may or may not behave like the original. It depends on what are considered as these "parameters" but it is still somewhat confusing.
What can i say about this situation.
- Can i use "(non)deterministic" to describe these
.clone()methods? All of them, some of them?
- Are they appropriately named? These never return exact copies of objects since they have
uuids, but one seems more "clone-like" than the other.
- what other rules and considerations could be made when cloning? Cloning attached event listeners and such may not be the best idea.