Skip to content

Instantly share code, notes, and snippets.

@tanem
Created March 3, 2011 21:07
Show Gist options
  • Save tanem/853562 to your computer and use it in GitHub Desktop.
Save tanem/853562 to your computer and use it in GitHub Desktop.
function logCar(car) {
console.log("I'm a " + car.color + " " + car.make);
}
logCar({ color: 'blue', make: 'BMW' });
function Car(make, color) {
this.make = make;
this.color = color;
}
Car.prototype.log = function() {
console.log("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