MacMac MacMac - 6 months ago 15
jQuery Question

First element in array - jQuery

How do you get the first element from an array:

var ary = ['first', 'second', 'third', 'fourth', 'fifth'];


I tried this:

alert($(ary).first());


But it would return
[object Object]
.

So I need to get the first element from the array which should be the element
first
.

Answer

like this

alert(ary[0])