Removing Elements from an Array
There are two methods available for removing elements from an array: pop and shift.
The pop method removes an element from the end of the array:
123let fruits = ["Apple", "Banana", "Cherry"]; fruits.pop(); console.log(fruits);
The shift element removes an element from the start of the array:
123let fruits = ["Apple", "Banana", "Cherry"]; fruits.shift(); console.log(fruits);
1. What does the pop method do in JavaScript?
2. What will be the output of the following code?
Tout était clair ?
Merci pour vos commentaires !
Section 1. Chapitre 61
Demandez à l'IA
Demandez à l'IA
Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion
Génial!
Completion taux amélioré à 1.33
Removing Elements from an Array
Glissez pour afficher le menu
There are two methods available for removing elements from an array: pop and shift.
The pop method removes an element from the end of the array:
123let fruits = ["Apple", "Banana", "Cherry"]; fruits.pop(); console.log(fruits);
The shift element removes an element from the start of the array:
123let fruits = ["Apple", "Banana", "Cherry"]; fruits.shift(); console.log(fruits);
1. What does the pop method do in JavaScript?
2. What will be the output of the following code?
Tout était clair ?
Merci pour vos commentaires !
Section 1. Chapitre 61