JavaScript di Radu TM β’ June 17, 2022
var fruits = ["π", "π", "π", "π"];
//change the position of "π" to the end of the array
var apple = fruits.shift();
fruits.push(apple);
console.log(fruits); //["π", "π", "π", "π"]
0
30.033
JavaScript di Radu TM β’ June 17, 2022
// creare un array con emoji frutti
var fruits = ['π', 'π', 'π'];
// spostare l'elemento all'indice 1 (π) alla fine dell'array
fruits.push(fruits.splice(1, 1)[0]);
// i frutti ora sono ['π', 'π', 'π']
// spostare l'elemento all'indice 2 (π) all'inizio dell'array
fruits.unshift(fruits.splice(2, 1)[0]);
// i frutti ora sono ['π', 'π', 'π']
0
30.033