We are committed to provide service 24 X 7

Deals, Shopping, Training, Tools

Javascript: Get element of array by index

While working in javascript, often there is a requirement to delete an element from an array by index. This article will discuss accessing an element from the javascript array by an index value.

Get an array element by index using [ ]

Example 1:-

Get the value of element at 3rd index position in array [1,4,9,16,25]

Advertisements

Code:-

let numArray = [1,4,9,16,25];
var value = numArray[3];
console.log(value);

Output:-

16

Note that the arrays have zero-based index.

Example 2:-

Get the value of element at 2nd index position in array [“Javascript”, “Is”, “Popular”, “Language”]

Code:-

let stringArray = ["Javascript", "Is", "Popular","Language"];
var value = stringArray[2];
console.log(value);

Output:-

Popular

Read More:

I hope this article helped you to get an element from an array by index position in javascript. Good Luck !!!

Cart

Your Cart is Empty

Back To Shop