Created
May 25, 2023 01:53
-
-
Save nicolasdanelon/ac4bed46e8dca524fd4b36f367f30f7b to your computer and use it in GitHub Desktop.
JS - OOP
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
class Humano { | |
constructor(n) { | |
this.nombre = n; | |
} | |
saludar() { | |
return `Hola, soy ${this.nombre}`; | |
} | |
} | |
const human = new Humano('Tomás'); | |
console.log(human.saludar()); | |
class Empleado extends Humano { | |
constructor(nombre, titulo) { | |
super(nombre); | |
this.titulo = titulo; | |
} | |
trabajar() { | |
return `Hola, vengo a trabajar. Soy ${this.titulo}`; | |
} | |
} | |
const employee = new Empleado('Yani', 'Desarrolladora web'); | |
console.log(employee.trabajar()); | |
console.log(employee.saludar()); |
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
// paradigma estructurado (C, Basic) | |
// paradigma funcional (oCamel, Haskell) | |
// paradigma objetos, POO o OOP (java, C#, php, etc) | |
class Humano { | |
saludar() { | |
return "Hola, soy un humano"; | |
} | |
} | |
const human = new Humano(); | |
console.log(human.saludar()); | |
class Empleado extends Humano { | |
trabajar() { | |
return "hola, vengo a trabajar" | |
} | |
} | |
const employee = new Empleado(); | |
console.log(employee.trabajar()); | |
console.log(employee.saludar()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment