Boolean objects in conditionals

Mark S. Miller erights at
Sat Nov 29 12:37:28 PST 2008

On Sat, Nov 29, 2008 at 5:40 AM, Lasse R.H. Nielsen <atwork at>wrote:

> = function() {
>   return this;
>  };
>  var n = (42).box();
> I would prefer to have "this" refer to a basic value instead when calling
> "methods on primitive values".
> I.e.:
>  (42).toString()
> should not be equivalent to "new Number(42).toString()", but to something
> simliar to "" that actually uses "42"
> as the value of "this".
> Alas, that's probably too big a change for 3.1 :(

It's not too big a change from ES3.1-strict, but it may be too late. If it's
not too late, I would be in favor of this change. (I have previously
advocated this change on es-discuss.) Note that = function() {
      "use strict";
      return this;
    var n = (42);

will correctly do what you want in ES3.1, so it seems a shame if we can't
fix the simpler form.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Es-discuss mailing list