Skip to content

Instantly share code, notes, and snippets.

@meagar
Created September 8, 2011 20:54
Show Gist options
  • Save meagar/1204679 to your computer and use it in GitHub Desktop.
Save meagar/1204679 to your computer and use it in GitHub Desktop.
Exercise 01 - functional vs OO
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