Skip to content

Instantly share code, notes, and snippets.

@pinouchon
Last active December 21, 2015 23:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pinouchon/6383057 to your computer and use it in GitHub Desktop.
Save pinouchon/6383057 to your computer and use it in GitHub Desktop.

http://jsfiddle.net/sxpVG/

var ford = new Car({
    model: 'ford',
    power: '20'
});
var tesla = new Car({
    model: 'tesla',
    power: '60'
});
var oldCar = new Car({});

ford.drive();
tesla.drive();
oldCar.drive();

function Car(params) {
    this.model = params.model || 'Lada';
    this.power = params.power || '0';

    this.drive = function () {
        console.log('driving a ' + this.model + ' with power ' + this.power);
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment