Object Oriented JavaScript with Getters and Setters for Properties. This is but just one example that seems rather friendly and straight forward. #OOP
var Person = new function () {
var _firstName = null;
var _lastName = null;
// Public Properties
this.FirstName = {
get: function () {
return _firstName;
},
set: function (value) {
_firstName = value;
}
};
this.LastName = {
get: function () {
return _lastName;
},
set: function (value) {
_lastName = value;
}
};
};
// Set First and Last Name Properties
Person.FirstName.set('John');
Person.LastName.set('Doe');
// Display Full Name
alert(Person.FirstName.get() + " " + Person.LastName.get());