Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
</body>
</html>
 
// Ejemplo 1
let yo = {
  nombre: 'yeison',
  edad: 22,
  hablar: function() {
    console.log(this.nombre);
  }
};
yo.hablar(); // yeison
// Ejemplo 2
let decirNombre = function(obj) {
  obj.hablar =  function() {
    console.log(this.nombre);
  };
};
const Mateo = {
  nombre: 'Mateo',
  edad: 22
};
const juan = {
  nombre: 'Juan',
  edad: 25
};
decirNombre(juan);
decirNombre(Mateo);
juan.hablar(); // Juan
Mateo.hablar(); // Mateo
// Ejemplo 3
let Persona = function (nombre, edad, madre) {
  return {
    nombre: nombre,
    edad: edad,
    hablar: function() {
    console.log(this.nombre);
    },
    madre: {
      nombre: madre,
      hablar: function() {
        console.log(this.nombre);
      }
    }
  };
};
const ana = Persona('Ana', 30, 'Clara');
ana.hablar(); // Ana
ana.madre.hablar(); // Clara
Output 300px

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
yeion7pro
0viewers