-
-
Save alexismellamo/c6b7b95e28e706ac7c3e827dc8715c0d to your computer and use it in GitHub Desktop.
Ejemplo crear objetos: puras funciones
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
let createPerson = (nombre, edad) => { | |
let getName = () => nombre; | |
return { | |
nombre, | |
edad, | |
getName, | |
} | |
} | |
let juan = createPerson('juan', 20); | |
juan.getName(); | |
let empleado = (persona, sueldo) => ({ | |
...persona, | |
sueldo, | |
getSalarioMensual: () => sueldo * 30 | |
}) | |
let empleadoJuan = empleado(juan, 100); | |
empleadoJuan.getSalarioMensual(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment