How to Get First Element of Array in Javascript?

By Hardik Savani November 5, 2023 Category : Javascript jQuery

Hey guys,

This tutorial will show you how to get the first element of an array using JavaScript. You will also learn how to do this using jQuery. I will demonstrate how to retrieve the first index value of an array in JavaScript. If you want to see an example of how to get the first index of an array using jQuery, you have come to the right place. Simply follow the example below for the jQuery array index selector.

Whenever you need to retrieve the first element value, you can use the following example. I will show you how to retrieve the first element value in jQuery. Let's take a look at the following example:

Example

<script type="text/javascript">


var languages = ["PHP", ".Net", "Java", "Javascript"];


var first_element = languages[0];

console.log(first_element);


</script>

I hope it can help you...

Tags :
Shares