Skip to content

Instantly share code, notes, and snippets.

@teffcode
Created May 20, 2020 03:05
Show Gist options
  • Select an option

  • Save teffcode/8ea3c505e61e5f0b2664a92713f4a9aa to your computer and use it in GitHub Desktop.

Select an option

Save teffcode/8ea3c505e61e5f0b2664a92713f4a9aa to your computer and use it in GitHub Desktop.

👋🏼 Welcome 👋🏼

Quiz banner

Instagram | Twitter | LinkedIn


👅 Choose your language



🚀 English version


What is the output of the following code ?

  A. ["⚽️"] 
  B. ["🎾"] 
  C. ["⚽️", "🏀"] 

👀 Click here to see the correct answer and explanation
Correct Answer Explanation
C. ["⚽️", "🏀"] The pop() method removes the last element from an array and returns that element. This method changes the length of the array. In this case, removing "🎾" from the array and printing console.log (ball) the result will be the two elements that will remain in the array 👉🏼 ["⚽️", "🏀"]

Explanation based on 👉🏼 Array.prototype.pop() | MDN



🚀 Spanish version


¿ Qué imprime el siguiente código ?

  A. ["⚽️"] 
  B. ["🎾"] 
  C. ["⚽️", "🏀"] 

👀 Haz click aquí para ver la respuesta correcta y su explicación
Respuesta correcta Explicación
C. ["⚽️", "🏀"] El método pop() se utiliza para eliminar el último elemento de un array y devuelve el elemento eliminado. En este caso, se elimina "🎾" del array y al imprimir console.log(ball) el resultado van a ser los dos elementos que quedaron en el array 👉🏼 ["⚽️", "🏀"]

Explicación basada en 👉🏼 JavaScript Array pop () | GeeksforGeeks



@JoelNieto90
Copy link
Copy Markdown

(function () {
var ball = ["⚽", "🏀", "🥎"]; // Declaramos el array
ball.pop(); // Metodo pop extra el elemento final del array

console.log(ball); // [ '⚽', '🏀' ]
})(); // Se auto ejecuta la funcion

Referencia: https://es.javascript.info/array

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment