get first array element javascript code example
Example 1: get first 10 items of array javascript
const list = ['apple', 'banana', 'orange', 'strawberry']
const size = 3
const items = list.slice(0, size)
Example 2: javascript how to get every element after the 1st in an array
var arguments = ['One', 'Two', 'Three'];
var middle = arguments.slice(1, -1);
console.log(middle);
Example 3: javascript get first element of array
let array = ["a", "b", "c", "d", "e"];
let [first1] = array;
let first2 = array[0];