Categories
JavaScript Answers

How to get the first element of an array with JavaScript?

Spread the love

To get the first element of an array with JavaScript, we use index 0.

For instance, we write

const array = ["first", "second", "third", "fourth", "fifth"];
alert(array[0]);

to get the first entry of array with array[0].

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published.