Re: indexed properties on NodeLists and HTMLCollections

On 5/5/11, Boris Zbarsky <bzbarsky@mit.edu> wrote:
> On 5/5/11 7:17 PM, Allen Wirfs-Brock wrote:
>> But native JS objects can also dynamically mutate in apparently arbitrary
>> ways:
>
> Yes, but "apparently" is the key part here.
>
>> var myGlobal = { };
>> alert(myGlobal.toString);  //built-in toString function
>> callSomeFunctionIdontKnowMuchAbout();
>> alert(myGlobal.toString);   //displays some other value because a toString
>> property was added to the myGlobal obj by the function
>> callAnotherFunctionIdontKnowMuchAbout();
>> alert(myGlobal.toString);  //built-in toString function because the
>> function deleted the property the new toString property from the obj
>
> Yes, but for this to happen the functions you call have to know
> something about myGlobal.

No, you don't.

Function `callSomeFunctionIdontKnowMuchAbout` could have created a
global property `myGlobal` or could do a for-in loop on the global
object itself.

Have to go to airport. Interesting discussion!
-- 
Garrett

Received on Friday, 6 May 2011 03:15:39 UTC