JS Fundamentals - Objects

by smichelotti

JavaScript

var Person = function(){
    this.firstName = "Steve";
    this.lastName = "Michelotti";

    this.sayHello = function(){
        console.log("Hello, my name is: " + this.firstName + " " + this.lastName);
    }
};

var person = new Person();
person.sayHello();
person.firstName = "John";
person.lastName = "Smith";
person.sayHello();