-
-
Save DavidPeralvarez/bb39c93c47539d0d6fcdcd03ef8d33bb to your computer and use it in GitHub Desktop.
JavaScript - Notación por corchetes
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
/* Objetos */ | |
var perro = { | |
nombre: 'Mel', | |
edad: 4, | |
raza: 'Border Collie', | |
adoptado: true, | |
dueno: { | |
nombre: 'David', | |
apellido: 'Perálvarez', | |
direccion: { | |
calle: 'Falsa', | |
numero: 123, | |
ciudad: 'Springfield' | |
}, | |
telefono: '3424234234' | |
}, | |
sociable: true | |
}; | |
var propiedad = 'edad'; | |
console.log( perro['raza'] ); | |
console.log( perro['dueno']['nombre'] ); | |
console.log( perro['dueno']['direccion']['calle'] ); | |
console.log( perro[propiedad] ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment