daytonn
2/19/2015 - 8:02 PM

CWCPOOJS - naive method definition

CWCPOOJS - naive method definition

// DO NOT define instance methods in this way

function Person(attributes) {
  this.firstName = attributes.firstName;
  this.lastName = attributes.lastName;
  this.age = attributes.age;
  this.address = attributes.address;
  this.sayHello = function() {
    console.log("Hi, my name is " + this.firstName + ". I live in " + this.address.city + ", on " + this.address.street + ".")
  };
}