Object.create - Node.js Object

Node.js examples for Object:Object Operation

Description

Object.create

Demo Code


var personProto = {
  calculateAge: function() {
    console.log(2017 - yearOfBirth);//ww w  .j  ava 2 s.  c  o  m
  }
};

var john = Object.create(personProto);
john.name = "John";
john.yearOfBirth = 1990;
john.job = "teacher";

var jane = Object.create(personProto,
{
  name: { value: "Jane" },
  yearOfBirth: {value: 1969 },
  job: {value: "designer" }
});

Related Tutorials