Skip to content

Instantly share code, notes, and snippets.

@agustinpfs
Last active July 7, 2020 19:51
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 agustinpfs/b7dd2fe2ecf4520f004590319070628a to your computer and use it in GitHub Desktop.
Save agustinpfs/b7dd2fe2ecf4520f004590319070628a to your computer and use it in GitHub Desktop.
Javascript básico. Objetos.
var persona = {
nombre: 'Juan',
edad: 28,
genero: 'masculino',
intereses: ['lectura', 'fútbol'],
biografia: function () {
console.log(this.nombre + ' tiene ' + this.edad + ' años. Le gusta la ' + this.intereses[0] + ' y jugar al ' + this.intereses[1] + '.');
},
saludo: function() {
console.log('Hola, soy '+ this.nombre + '. ');
}
};
console.log(persona.nombre) // Juan
console.log(persona.edad) // 28
console.log(persona.intereses[1]) // lectura
persona.biografia() // Juan tiene 28 años. Le gusta la lectura y jugar al fútbol.
persona.saludo() // Hola, soy Juan.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment