Let a = {a: 1, b:2}, whichs shows in console Object {a: 1, b: 2}.
When I do a.a I get 1.
When I do a[a] I get undefined.
Is it normal ?
I'm asking this because I need to get values from dynamic keys. a[product1], a[product2]....
Yes, this is normal.
a[a] is the same as a[a.toString()] which is the same as a['[object Object]'] and you haven't defined a property with that name in the object.
If you want to use square bracket notation to access a property called a then you have to pass a string with the value a: a['a'] or var prop = 'a'; a[prop].
a.ais getting propertyaof objecta.a[a]is trying to get an array element.athe latter is getting the property with the name that is the same as the string value ofa. It has nothing to do with arrays.{ product: [val, val, val] }) and afor i=1; i<array.length; i++loop.