I don’t know what it is called or I would look it up, but when acsessing an object or arrays element in jQuery what is the differance between Obj.element and Obj[”element”]?
1 Answer
Obj.element and Obj[”element”]
Both these will access the same key element inside object Obj. Value against key name "element" will be returned.
4 Comments
Andrew Li
@IsaacS.Weaver Well, arrays are just objects with the keys 0, 1, 2, etc. You can't do arr.0 so you do arr[0]. It's the same operation.
Patrick Evans
Note
arr[0] is equivalent to arr["0"], as property names are strings (or symbols)Kaps
@IsaacS.Weaver dot notation doesn't work on arrays, although arrays are objects with keys starting from 0 and incrementing for every push operation.
Isaac S. Weaver
Perfect that answers my question completely! Thank you all!!
element