Skip to content

Instantly share code, notes, and snippets.

@alexismellamo
Forked from GeDiez/.js
Created March 20, 2018 23:48
Show Gist options
  • Save alexismellamo/c6b7b95e28e706ac7c3e827dc8715c0d to your computer and use it in GitHub Desktop.
Save alexismellamo/c6b7b95e28e706ac7c3e827dc8715c0d to your computer and use it in GitHub Desktop.
Ejemplo crear objetos: puras funciones
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