document.getElementsByTagName('a').item(0)
and
document.getElementsByTagName('a')[0]
will return the same result…
Is the former faster than the latter?
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.
Selfmade performance test: http://jsfiddle.net/438jh/2/
The difference seems to be negligible. The second method performs better in most case, but if you have a look on how often the loop is performed it does not really matter.
Chrome: