W3C home > Mailing lists > Public > public-script-coord@w3.org > July to September 2011

Re: [Constructor] and [NamedConstructor]

From: Brendan Eich <brendan@mozilla.org>
Date: Mon, 22 Aug 2011 23:05:31 -0700
Cc: David Flanagan <dflanagan@mozilla.com>, public-script-coord@w3.org
Message-Id: <7EE8B274-BEF4-48BC-9C5F-56814F223708@mozilla.org>
To: Cameron McCormack <cam@mcc.id.au>
On Aug 22, 2011, at 8:31 PM, Cameron McCormack wrote:

> Does that mean you consider this native JS function not to be a "true constructor":
> 
>  function F() {
>    return { };
>  }
> 
> ?  Although with some implementations it might be less efficient to use new to invoke these constructors, I don't think it's going to be significant.  Implementations could well optimise these cases anyway. I'm not sure these notes would be useful.

All the finest ;-) optimizing JS VMs avoid making a new Object instance for new F.


>> 3) 4.5.2 doesn't say anything about the prototype property of a named
>> constructor function. Shouldn't it have one, and shouldn't it have the
>> same value as the prototype property of the interface object? (Note that
>> FF and Chrome do not do this for Image(), but Safari does)
> 
> Safari/IEPP: Image.prototype == HTMLImageElement.prototype
> Chrome: Image.prototype.[[Prototype]] == HTMLImageElement
> Firefox: Image.prototype.[[Prototype]] == HTMLElement.prototype
> Opera: Image.prototype === undefined
> 
> I agree, the Safari/IE behaviour makes most sense to me.

Agreed.

/be
Received on Tuesday, 23 August 2011 06:06:20 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 8 May 2013 19:30:04 UTC