Looking things up in that method foo["bar"] rather than foo.bar, is slow and
can cause runtime exceptions if you don't check foo.hasOwnProperty("bar").

You're better off having a foo.bar = Array(), and doing foo.bar[n] rather
than foo["bar" + n] whenever possible.

The only time you really want to use this sort of syntax is when you're
building an assosc. array at runtime and you can't know what the key names
will be (eg, it's generated from user-input, or perhaps some framework
code).

-J

On Tue, Mar 25, 2008 at 12:38 PM, Tracy Spratt <[EMAIL PROTECTED]>
wrote:

>    I have seen and used the term "bracket notation".  Don't know how
> common it is.
>
>
>
> Kevin, why do you allege "bad practice"?  What are you referring to for
> that matter?
>
>
>
> Tracy
>
>
>  ------------------------------
>
> *From:* [email protected] [mailto:[EMAIL PROTECTED] *On
> Behalf Of *Kevin Aebig
> *Sent:* Monday, March 24, 2008 9:47 PM
> *To:* [email protected]
> *Subject:* RE: [flexcoders] What's this Called?
>
>
>
> That's called bad practice. The lookup method you're referring to is
> called an associative array or dictionary.
>
>
>
> !k
>
>
>  ------------------------------
>
> *From:* [email protected] [mailto:[EMAIL PROTECTED] *On
> Behalf Of *Nate Pearson
> *Sent:* Monday, March 24, 2008 6:18 PM
> *To:* [email protected]
> *Subject:* [flexcoders] What's this Called?
>
>
>
> When I do this["idOfsomethingImLookingfor"]
>
> I usually do this if I have to loop something.
>
> So:
>
> for (i=0; i<10; i++){
> var example:Object = this["myComponent" + i]
> //do some more stuff
> }
>
> I'm trying to do the same thing in .NET. I don't know what it's
> called though so I'm having a hard time googling it.
>
> Thanks,
>
> Nate
>
>  
>



-- 
"Therefore, send not to know For whom the bell tolls, It tolls for thee."

:: Josh 'G-Funk' McDonald
:: 0437 221 380 :: [EMAIL PROTECTED]

Reply via email to