On Tue, 12 Apr 2011 07:55:26 +0200, Allen Wirfs-Brock <[email protected]> wrote:


On Apr 11, 2011, at 6:45 PM, Axel Rauschmayer wrote:

var obj={}.valueOf.call(obj); // ToObject in case primitive value passed
...
{}.valueOf is the same value as Object.prototype.valueOf assuming none of the standard definitions have been over-written. See the comment thread of http://www.wirfs-brock.com/allen/posts/166 for a debate as to which of these forms is more or less optimizable.

Object.prototype.valueOf as specified is essentially a call to the internal ToObject operation that wrappers primitive values. I put it in to deal with cases like getDefiningObject("some string", "match")


In that case, why not just
  obj = Object(obj);

It has the added advantage of not returning the global object for null and undefined, but just a plain new object (although either can be said to be wrong in this case).

/L
--
Lasse Reichstein - [email protected]
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to