Created
August 13, 2019 22:19
Star
You must be signed in to star a gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Remover elementos de un arreglo | |
* en JavaScript | |
* | |
* @author parzibyte | |
* | |
* https://parzibyte.me/blog | |
*/ | |
const canciones = [ | |
"Fox on the run", | |
"Start me up", | |
"Miss You", | |
"Suspicious Minds" | |
]; | |
console.log("Las canciones antes: ", canciones); | |
let cancionQueSeElimina = "Fox on the run"; | |
// Buscar su índice | |
let indice = canciones.indexOf(cancionQueSeElimina); | |
canciones.splice(indice, 1); | |
console.log("Las canciones después: ", canciones); | |
/* | |
Salida | |
Las canciones antes: [ 'Fox on the run', | |
'Start me up', | |
'Miss You', | |
'Suspicious Minds' ] | |
Las canciones después: [ 'Start me up', 'Miss You', 'Suspicious Minds' ] | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment