On Tue, Apr 5, 2011 at 5:29 PM, mcot <[email protected]> wrote:
>
> Thanks.  I did find this:
>
> https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Object/noSuchMethod
>
> But that seems to be only useful for methods, not properties.
>
> I am running untrusted 3rd party code, so using || is out of the
> question.
>
> On Apr 5, 10:45 am, Peter van der Zee <[email protected]> wrote:
>> On Tue, Apr 5, 2011 at 10:38, mcot <[email protected]> wrote:
>> > I was wondering if you could have a function serve as the default
>> > function that gets called when a property is accessed.
>>
>> On Tue, Apr 5, 2011 at 4:40 PM, Gary Katsevman 
>> <[email protected]>wrote:
>>
>> > I don't think that exists. Instead use the defaults operator `||' like so:
>>
>> Correct.
>>
>> Currently there are no magic "catch-all" mechanisms in the language.
>> Something called "proxies" are planned for the future. And some browsers
>> (most notably Firefox) allow you to create such catch-alls through the
>> __getter__ (I believe?) property, if you want to experiment.
>>
>> - peter
>
> --
> To view archived discussions from the original JSMentors Mailman list: 
> http://www.mail-archive.com/[email protected]/
>
> To search via a non-Google archive, visit here: 
> http://www.mail-archive.com/[email protected]/
>
> To unsubscribe from this group, send email to
> [email protected]
>

There is an automated invocation the interpreter does on the
".valueOf()" method of objects when they are converted to primitive
value.

var a = new Object();
a.valueOf = function() { alert("x"); };
void(a + 1);

I really don't know if you can make something out of this behavior.

You can read more detailed info here:

    
https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Object/valueOf

or here:

    http://www.aptana.com/reference/html/api/Object.html

search for "valueOf" in the text and read the detailed informations
there, it may give you some tip.


Diego

-- 
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/[email protected]/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/[email protected]/

To unsubscribe from this group, send email to
[email protected]

Reply via email to