>
>
>  Why it is better to use a function instead of direct access?
>
>
It's not always better.

Push is far better when you're not sure what the next index of your array
is. for example:

[87, 2, 369, , , , 42, 53]

If i remember correctly .length will return 5, which means if you started
adding in items from that point, you'll eventually overwrite other items in
the array.

Direct access is useful when you are creating the array from scratch, for
instance holding the properties of a object.

--
Rob Griffiths
http://bytespider.eu
@bytespider <http://twitter.com/bytespider>

https://github.com/bytespider

-- 
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/jsmentors@jsmentors.com/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/jsmentors@googlegroups.com/

To unsubscribe from this group, send email to
jsmentors+unsubscr...@googlegroups.com

Reply via email to