Accessing Js object properties :
What is the difference between :
1) Obj.src
vs
2) Obj["src"]
I only know that #1 can’t be used with number ( e.g. if the property name is “1”)
Is there any other major differences ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No difference really. Old’ish browser showed some performance differences using either the one or the other notation, but those times are over.
The only important difference is that the bracket notation is your only chance to dynamically access Object properties.
For instance:
you can’t do that using a dot notation.