quick javascript properties query

Soldato
Joined
6 Mar 2008
Posts
10,085
Location
Stoke area
hi,

Just working through some tutorials on Javascript and it's use in HTML5 and we've just started on objects (which I think are just arrays of data).

However, it's talking about properties of objects and shows two examples

fido.weight - which is 40
fido["breed"] - which is mixed

it makes out that you should always use the ["string"] method when the property is a string and the . method when it's a integer but doesn't really explain why.

I've tried the . method with both and it works fine.

Is there a reason to use them both or is it industry standard to just use the . method? :)

noob question I know but I don't like bad habits.
 
Back
Top Bottom