[Laszlo-dev] For Review: Change change.YnPVbvuCF.txt Summary: Rewrite LzTimer to use setInterval/clearInterval instead of LzIdle

P T Withington ptw at openlaszlo.org
Wed Jun 28 13:32:45 EDT 2006


On 2006-06-28, at 12:45 EDT, Jim Grandy wrote:

>> I'm confused.  How can this work:  `this.timerList[d]` (where d is  
>> a delegate, hence an object?)
>>
> Hrm? It certainly does work. You can use any object as a key in  
> JavaScript, no?

I am pretty sure Object keys are strings, although I can't find where  
it says that in ECMA.  When you use something other than a string as  
a key, the value is converted by String(key), so for a general Object  
it will call key.toString().  So, you _could_ make this work by  
giving delegates a toString method that guaranteed to generate unique  
strings.  (I assumed this is why you are testing for the return value  
from setInterval to _not_ be an object?)

js> var foo = { id: 'foo', toString: function () { return "test" } }
js> var bar = { id: 'bar', toString: function () { return "test" } }
js> var obj = {}
s> obj[foo] = foo
test
js> obj[bar] = bar
test
js> obj[foo] === foo
false
js> obj[foo] === bar
true
js>


More information about the Laszlo-dev mailing list