On Mar 11, 2009, at 10:33 AM, Garrett Smith wrote:

[overlong cited text cut -- please do that when replying. /be]

What text in the link you give made you think anything of the sort? I see no
use of "internally" or "internal" in that wiki page. You can override
toSource just as you can override toString. Doing so in a content window
cannot possibly affect the operation of the browser's user interface
("chrome") windows.


I prefer to use the term "shadow" to override. In the example below,
C.prototype.toSource shadows Object.prototype.toSource;

Ok, but what does this have to do with the price of eggs?


function C(){
 this.name = "c1";
}

C.prototype = {
 name : "c",
 title : "a C object",
 toSource : function() {
   return this.name + "::C\n" +
   Object.prototype.toSource.call(this);
 }
};

Result:
c1::C
({name:"c1"})

Perhaps you would like to use a for-in loop to debug properties;
for(var p in this) {
 // build a string.
}

?

If you mean that overriding or shadowing by assignment makes an enumerable property, even for a method that should not be enumerated, then ES3.1's Object.defineProperty allows binding a non-enumerable property.

But I still can't tell what your point is. It seems to be unrelated to my question asking Tobie what the problem with overriding toSource (as opposed to toString, and without dragging in any unrelated problem in common to do with enumerability, which is irrelevant!) might be.

/be


Garrett

/be



Best,

Tobie

[1]
https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Object/toSource


On Mar 11, 2009, at 00:01 , Jason Orendorff wrote:

On Sat, Mar 7, 2009 at 9:18 PM, Tobie Langel <[email protected] >
wrote:

The lack of a more developer-friendly representation of objects than the
one
obtained through their toString method (or by calling
Object.prototype.toString) made me long for an ES equivalent of Ruby's
inspect instance method.

You could use JSON.stringify(obj), which is on track to be
standardized in ES3.1.

(SpiderMonkey has the nonstandard uneval, as well as
Object.prototype.toSource, which I think are a bit closer to what you
want.)

-j

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

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


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

Reply via email to