On Sat, Nov 29, 2008 at 5:40 AM, Lasse R.H. Nielsen <[EMAIL PROTECTED]>wrote:
> Number.prototype.box = 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 "Number.prototype.toString.call(42)" 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
Number.prototype.box = function() {
"use strict";
return this;
}
var n = (42).box.call(42);
will correctly do what you want in ES3.1, so it seems a shame if we can't
fix the simpler form.
--
Cheers,
--MarkM
_______________________________________________
Es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss