How can I log an ArrayIndex out of bound in JavaScript?

Viewed 8328

I have the array var john = ['asas','gggg','ggg'];

If I access john at index 3, ie. john[3], it fails.

How can I display a message or alert saying that there is no value at that index?

6 Answers
Related