Typeof this in getters (was: eval on non-strings)

Mark S. Miller erights at google.com
Tue Feb 28 11:38:28 PST 2012

I like the output display on http://jsfiddle.net/CxdMs/16/ a bit better. I
just tried it on very recent versions of 4 or the 5 major browsers. I was
shocked to see that all of them were wrong.

Correct would be

    number      number
    object        object

Chrome 19 gave

    number      number
    object        number

Opera 12, Safari WebKit 5.1.3 (7534.53.10, r109097), and Mozilla FF Nightly
13 all gave

    number      object
    object        object

What does the latest IE10 preview do?

Domenic, as you post bugs against the browsers, please send me the URLs.

On Tue, Feb 28, 2012 at 10:03 AM, Domenic Denicola <
domenic at domenicdenicola.com> wrote:

> > Specifically regarding ToObject.  It's use is important in minimizing
> the semantic differences between primitive values and Objects. In ES5 we
> eliminated the automatic wrapping of primitive values  used as this values
> in method invocations.  That means that in most cases 42 and (new
> Number(42)) can be used interchangeably. If we start leaving out ToObject
> calls in random places the distinction between a primitive value and a
> wrapped primitive values will start tripping people up.
> This actually is apropos of something I'd been meaning to ask about.
> Consider the following JSFiddle:
> http://jsfiddle.net/CxdMs/15/
> It seems reasonably clear that the result for functions should be object
> (non-strict)/number (strict), according to section 10.4.3.
> But for getters, the major browsers disagree, and my spec-fu can't find
> anything besides the abovementioned section. Firefox and IE9 say
> object/object, while V8 says number/number. And at least one version of
> JavaScriptCore we have lying around says number/object. If someone could
> walk me through the spec correctly, I'd be happy to file appropriate
> browser bugs.
> Note that this is a real-world issue. The Chai.js assertion library is
> trying to break free of V8 and become useful in browsers, but is
> encountering problems due to this behavior:
> https://github.com/logicalparadox/chai/issues/32
> Thanks all,
> Domenic
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120228/b4d4fa3f/attachment.html>

More information about the es-discuss mailing list