change position of element in array javascriptmdn code example
Example 1: es6 remove first element of array
var myarray = ["item 1", "item 2", "item 3", "item 4"];
//removes the first element of the array, and returns that element.
alert(myarray.shift());
//alerts "item 1"
//removes the last element of the array, and returns that element.
alert(myarray.pop());
//alerts "item 4"
Example 2: access index of array javascript
let first = fruits[0]
// Apple
let last = fruits[fruits.length - 1]
// Banana