// Part 2
var profile = {
__firstName__: "",
__lastName__: "",
set firstName(fn) {
this.__firstName__ = fn;
},
set lastName(ln) {
this.__lastName__ = ln;
},
get fullName() {
return this.__firstName__ + " " + this.__lastName__;
}
};
profile.firstName = "Old";
profile.lastName = "Snake";
console.log(profile.fullName);
// Part 3
function Profile(fn, ln) { this.__firstName__ = fn; this.__lastName__ = ln; };
Profile.prototype.__defineSetter__("firstName", function(fn) {this.__firstName__ = fn;});
Profile.prototype.__defineSetter__("lastName", function(ln) {this.__lastName__ = ln;});
Profile.prototype.__defineGetter__("fullName", function() {return this.__firstName__ + " " + this.__lastName__;});
var profile1 = new Profile("Old", "Snake");
console.log(profile1.fullName);
var profile2 = new Profile("Revolver", "Ocelot");
console.log(profile2.fullName);
Archive for the Category » AJAX «
Monday, September 08th, 2008 | Author: Admin
Category: AJAX
| Comments off
