david.bruant at labri.fr
Sat May 7 16:43:48 PDT 2011
Le 07/05/2011 20:44, Douglas Crockford a écrit :
> On 11:59 AM, Oliver Hunt wrote:
>> It does annoy me that these were not made immutable. The safest way
>> to create an object is still either with an object literal or new
>> I'm not convinced that Object.create added anything of value to the
>> language, and certainly wouldn't recommend
>> its use for general object creation.
> I disagree. Object.create is the foundation of a system of delegation.
I agree. Object.create is what should have been present in the first
place. Even before functions as constructors. Even before putting
Object.prototype as the default prototype object for the object literal
(in ES5, calls "new Object()" which sets the [[Prototype]] to the
standard built-in Object prototype object. See 11.1.5 then 22.214.171.124 step
4). One strawman even suggests an extension to object literals in order
to declare the prototype object 
Object.create is the "easiest" abstraction based on which, other
constructs can be created. It gets back to the basic definition of what
an object is (ES5 4.3.3): "An object is a collection of properties and
has a single prototype object. The prototype may be the null value."
Before Object.create, there was no easy way built-in in the language to
create an object following this definition. You had to create the
abstraction yourself. With Object.create, the abstraction is natively
here (properties are also considered with the second optional argument).
More information about the es-discuss