ES3.1 Object static methods rationale document

Maciej Stachowiak mjs at
Wed Jul 16 17:50:01 PDT 2008

On Jul 16, 2008, at 4:10 PM, Allen Wirfs-Brock wrote:

> The most common use case seems to be the one where the target object  
> is a newly instantiated object without any properties of its own.  
> That use case (at least for variants of extend that only take a  
> single source object) is most directly supported by the Object.clone  
> function in our proposal. However, Object.clone is defined to be a  
> more comprehensive object duplication process than is performed by  
> extend.  It duplicates all own properties and their attributes and  
> any internal properties such as its [[Value]] property if it has one.

1) It seems like Object.clone as you have described it is not suitable  
for the "mixin" type use case where an object gets properties/methods  
from two others. Or at least, it only does half the job.

2) Is Object.clone expected to work on host objects (in particular DOM- 
related objects)? I think thorough cloning of all state is not a  
practical semantic in that case, and would be a very large burden on  
implementations. In the case of some classes (Window or Location for  
instance) allowing true cloning might even be a security risk. And if  
it does not support host objects then copying internal state like the  
[[Value]] or [[Class]] property for ES standard object types will be  
more confusing than helpful.


More information about the Es4-discuss mailing list