W3C home > Mailing lists > Public > public-webapi@w3.org > December 2007

Re: [Bindings] stringify

From: liorean <liorean@gmail.com>
Date: Mon, 31 Dec 2007 13:44:13 +0100
Message-ID: <cee13aa30712310444w6588306ct96cb1ef3d86b6ae1@mail.gmail.com>
To: "Web APIs WG (public)" <public-webapi@w3.org>

> On Dec 30, 2007 7:19 PM, Cameron McCormack <cam@mcc.id.au> wrote:
> > You can however use Object.prototype.toString.call() to ensure you are
> > getting Object's version of toString(), and not some overridden version:
> >
> >   >>> Object.prototype.toString.call("[object Window]")
> >   [object String]

On 31/12/2007, Garrett Smith <dhtmlkitchen@gmail.com> wrote:
> Yeah, that is true.
> But not 100% foolproof:
> Function.prototype.call uses the calling context when arg0 is undefined or null.
> Object.prototype.toString.call( undefined )
> Object.prototype.toString.call( null )

It uses the global object if the first argument is not what the
ECMAScript spec calls "an object". The only things in ECMAScript that
are not "an object" are null and undefined. Those should be handled by
user code respectively. Anyone who knows ECMAScript well enough to
know about Function.prototype.call and function.prototype.apply
probably knows this. In any case, that's entirely the domain of
ECMAScript and not the DOM bindings, IMO.

> On Dec 30, 2007 7:19 PM, Cameron McCormack <cam@mcc.id.au> wrote:
> > You can rely on the string between "[object " and "]" to be the
> > [[Class]] of the object.  (Well, assuming Object hasn't been changed.)

I think ES4 will make the standard library global constructor object
bindings {ReadOnly, DontDelete}, but IIRC there's been some discussion
that it might break more scripts than it helps, so it might not
David "liorean" Andersson
Received on Monday, 31 December 2007 12:44:28 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:16:24 UTC