Created
September 29, 2010 19:30
-
-
Save ZenCocoon/603376 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
// Example call for functional version: | |
function logCar(object) { | |
return "I'm a " + object.color + " " + object.make | |
} | |
logCar({ color: 'blue', make: 'BMW' }); | |
// Example call for OO version: | |
var Car = function(make, color) { | |
this.make = make; | |
this.color = color; | |
}; | |
Car.prototype.log = function() { | |
return "I'm a " + this.color + " " + this.make; | |
}; | |
(new Car('Ferrari', 'red')).log(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment