Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

When you do "var B = Object.create(A);", should B be called a clone of A or a copy of A?

I have seen various definitions of the term "clone", e.g. Io language documentation says that "a clone is an empty object that has the parent in its list of protos", this article defines clone as an exact shallow copy of another object.



> When you do "var B = Object.create(A);", should B be called a clone of A or a copy of A?

Neither. In Self lingo, A is a mixin of B. The least bad wording would be centered around composition, but I guess it could also be understood that B is an extension of A.

It can't be a clone or a copy, because changing A will still impact B, they don't become independent objects.


I would prefer to call B a child of A as it can be instantiated with its own properties.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: