-
-
Save DavidPeralvarez/1f19c0bab122851bc69347c338807a1b to your computer and use it in GitHub Desktop.
JavaScript - Las clases antes de las clases
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
var serie = {}; | |
console.log( serie ); | |
// Función = Clase = Objeto | |
function Serie( titulo, puntuacion, plataforma ){ | |
// Propiedades | |
// this.titulo = 'La casa de papel'; | |
// this.puntuacion = 8.5; | |
// this.plataforma = 'Netflix'; | |
// Constructor | |
this.titulo = titulo; | |
this.puntuacion = puntuacion; | |
this.plataforma = plataforma; | |
// Métodos | |
this.detallesSerie = function(){ | |
return 'Título: ' + this.titulo + ' | Puntuación: ' + this.puntuacion + ' | Ya disponible en: ' + this.plataforma; | |
} | |
} | |
// Instancia | |
var serie1 = new Serie( 'La casa de papel', 8.5, 'Netflix' ); | |
var serie2 = new Serie( 'Silicon Valley', 7, 'HBO' ); | |
console.log( serie1 ); | |
console.log( serie1.detallesSerie() ); | |
console.log( serie2 ); | |
console.log( serie2.detallesSerie() ); | |
console.log( serie1 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment