Answers for "how to select the first element of an array ks"

14

javascript take first element of array

const array = [1,2,3,4,5];
const firstElement = array.shift();

// array -> [2,3,4,5]
// firstElement -> 1
Posted by: Guest on May-06-2020
2

javascript select first n elements from array

const array = ['toto','tata','titi','tutu'];

array.slice(0, 2); // => ['toto','tata']
Posted by: Guest on March-08-2021

Code answers related to "how to select the first element of an array ks"

Code answers related to "Javascript"

Browse Popular Code Answers by Language