javascript first index of array code example
Example 1: javascript take first element of array
const array = [1,2,3,4,5];
const firstElement = array.shift();
Example 2: index of value in array
var imageList = [
{value: 100},
{value: 200},
{value: 300},
{value: 400},
{value: 500}
];
var index = imageList.findIndex(img => img.value === 200);
Example 3: js array get index
var fruits = ["Banana", "Orange", "Apple", "Mango"];
return fruits.indexOf("Apple");
Example 4: javascript get first element of array
let mylist = ['one','two','three','last']
mylist[0],mylist[1],mylist[2],mylist[3]