Custom prototype

by Wentz Wu

JavaScript

function Person(firstName, lastName) {
  var person = {};
  person.firstName = firstName;
  person.lastName = lastName;
  return person;
}


var bruce = new Person("bruce","wu");
Person.prototype.say = function(){return "hello";};
bruce.__proto__ = Person.prototype;
console.log(bruce.say());