Skip to content

Instantly share code, notes, and snippets.

@DavidPeralvarez
Created April 7, 2020 11:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DavidPeralvarez/ce37d1f028094467fd41ef9d76312431 to your computer and use it in GitHub Desktop.
Save DavidPeralvarez/ce37d1f028094467fd41ef9d76312431 to your computer and use it in GitHub Desktop.
JavaScript - Los arreglos
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Curso de Javascript</title>
</head>
<body>
<script src="scripts.js"></script>
</body>
</html>
/* Arreglos */
var arreglo = [];
console.log( arreglo );
var listaCompra = [ 'sal', 'salmón', 'pan', 'detergente', 'salsa de soja' ];
console.log( listaCompra );
console.log( listaCompra[3] );
console.log( listaCompra[1] );
console.log( listaCompra.length );
console.log( listaCompra[ listaCompra.length - 1 ] );
var listaRandom = [
'texto',
15,
{
color: 'rojo',
producto: 123123123,
tipo: 'camiseta'
},
function(){ console.log( 'Mensaje función' ) },
false,
[ 1, 2, 3, 4, 5 ]
];
console.log( listaRandom[2].producto );
listaRandom[3]();
console.log( listaRandom[5][3] );
var listado2 = listaRandom[5];
console.log( listado2 );
listado2[2] = 'hola qué tal';
console.log( listado2 );
console.log( listaRandom );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment