Created
September 8, 2011 20:54
-
-
Save meagar/1204679 to your computer and use it in GitHub Desktop.
Exercise 01 - functional vs OO
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
function logCar(car) { | |
console.info("I'm a", car.color, car.make); | |
} | |
function Car(make, color) { | |
this.make = make; | |
this.color = color; | |
} | |
Car.prototype.log = function () { logCar(this); } | |
// Example call for functional version: | |
logCar({ color: 'blue', make: 'BMW' }); | |
// 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