If you are not using sequentially numbered elements, you will have to go through until you press the first one:
var firstIndex = 0;
while (firstIndex < myarray.length && myarray[firstIndex] === undefined) {
firstIndex++;
}
if (firstIndex < myarray.length) {
var firstElement = myarray[firstIndex];
} else {
}
or some equivalent stupid construct. This gives you the first element index, which you may or may not need.
-, , O (1), O (n) . , , , , -, .