Created
November 11, 2011 05:44
-
-
Save jasonmw/1357300 to your computer and use it in GitHub Desktop.
Homework 1 from Mastering JS Class
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
var logCar = function(){ | |
var inp = arguments[0]; | |
return function(){ | |
console.log("I'm a " + inp.color + ' ' + inp.make); | |
}; | |
}; | |
var Car = function(make,color){ | |
this.make = make; | |
this.color = color; | |
} | |
Car.prototype.log = function(){ | |
console.log("I'm a " + this.color + ' ' + this.make); | |
}; | |
var Car2 = function(make,color){ | |
this.make = make; | |
this.color = color; | |
this.log = function(){console.log("I'm a " + this.color + ' ' + this.make);}; | |
} | |
// tests | |
logCar({ color: 'blue', make: 'BMW' })(); | |
(new Car('Ferrari', 'red')).log(); | |
(new Car2('Ferrari', 'red')).log(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment