-
-
Save DavidPeralvarez/ff6de31c74bd9a71d4130ab38d9c6267 to your computer and use it in GitHub Desktop.
JavaScript - Métodos de los arreglos
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Curso de Javascript</title> | |
</head> | |
<body> | |
<script src="scripts.js"></script> | |
</body> | |
</html> |
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
/* Arreglos */ | |
var animales = [ 'perros', 'gatos', 'gallinas', 'elefantes' ]; | |
console.log( animales ); | |
// console.log( Array.isArray( animales ) ); | |
// console.log( animales.pop(), animales ); | |
// console.log( animales.push( 'vacas' ), animales ); | |
// console.log( animales.unshift( 'vacas' ), animales ); | |
// console.log( animales.splice( 1, 1, 'caballos', 'conejos' ), animales ); | |
// console.log( animales.slice( 2, 4 ), animales ); | |
// var animales2 = animales.map( function( el ){ | |
// return 'Tengo: ' + el; | |
// } ); | |
// console.log( animales2 ); | |
// console.log( animales.indexOf( 'gallinas' ) ); | |
// console.log( animales.reverse() ); | |
console.log( animales.sort() ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment