// =======================
// Constructor
// =======================
function Person(firstName, lastName)
{
this.firstName = firstName;
this.lastName = lastName;
}
// =======================
// Instance methods
// =======================
Person.prototype.getFirstName = function()
{
return this.firstName;
}
Person.prototype.getLastName = function()
{
return this.lastName;
}
Person.prototype.getGreeting = function(greeting)
{
return greeting + ' ' + this.firstName + ' ' + this.lastName;
}
// =======================
// Usage
// =======================
function test()
{
this.person = new Person('Chris', 'Newland');
console.log(this.person.getGreeting('Hello'));
}
// Constructor
// =======================
function Person(firstName, lastName)
{
this.firstName = firstName;
this.lastName = lastName;
}
// =======================
// Instance methods
// =======================
Person.prototype.getFirstName = function()
{
return this.firstName;
}
Person.prototype.getLastName = function()
{
return this.lastName;
}
Person.prototype.getGreeting = function(greeting)
{
return greeting + ' ' + this.firstName + ' ' + this.lastName;
}
// =======================
// Usage
// =======================
function test()
{
this.person = new Person('Chris', 'Newland');
console.log(this.person.getGreeting('Hello'));
}