document.getElementsByTagName('a').item(0)
and
document.getElementsByTagName('a')[0]
will return the same result...
Is the former faster than the latter?
python lists are 0-indexed. So the first element is 0, second is 1, so on. So if the there are n elements in a list, the last element is n-1. Remember this!
Why might you prefer to use a range over a list? Ranges do not instantiate their elements, making them more efficient in loops. Ranges are a type of list, and support all list methods as well as some special methods for range objects. Creating a range is faster than creating a list, but lists require less memory.
No. A list is an object.
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:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With