Created
March 3, 2011 21:09
-
-
Save muloka/853572 to your computer and use it in GitHub Desktop.
JSMC Exercise 3
This file contains 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
// functional | |
var logCar = function (obj){ | |
return function(){ | |
"I'm a" + obj.color + " " + obj.make; | |
} | |
} | |
// Example call for functional version: | |
logCar({ color: 'blue', make: 'BMW' }); | |
// oo | |
var Car = function (color,make){ | |
this.color = color; | |
this.make = make; | |
} | |
Car.prototype.log = function() { | |
return "I'm a" + this.color + " " + this.make; | |
} | |
// Example call for OO version: | |
(new Car('Ferrari', 'red')).log(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment