Created
February 3, 2011 17:27
-
-
Save balinterdi/809817 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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