Skip to content

Instantly share code, notes, and snippets.

@balinterdi
Created February 3, 2011 17:27
Show Gist options
  • Save balinterdi/809817 to your computer and use it in GitHub Desktop.
Save balinterdi/809817 to your computer and use it in GitHub Desktop.
Address = function(options) {
this.city = options.city || 'Budapest';
this.country = options.country || 'Hungary';
this.street = options.street || 'Szep utca';
this.summary = function() {
return this.street + ', ' + this.city + ', ' + this.country + ' (' + this.type + ')';
};
}
Object.create = function(o) {
var F = function() {};
F.prototype = o;
return new F();
}
var fields = { street: 'Huba vezer utca' };
Billing = function(options) {
this.type = 'BI';
}
Billing.prototype = new Address(fields);
Shipping = function(options) {
this.type = 'SH';
}
Shipping.prototype = new Address(fields);
//var bi = Object.create(new Address({ street: 'Huba vezer utca' }));
//bi.type = 'BI';
//
//bi = new Billing({ street: 'Huba vezer utca' });
//sh = new Shipping({ country: 'US', city: 'San Francisco', street: 'Main Street' });
bi = new Billing();
sh = new Shipping();
print(bi.summary());
print(sh.summary());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment