Skip to content

Instantly share code, notes, and snippets.

@anddoutoi
Last active January 27, 2017 23:42
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 anddoutoi/45ad71d38d81aa401ca61097536eb935 to your computer and use it in GitHub Desktop.
Save anddoutoi/45ad71d38d81aa401ca61097536eb935 to your computer and use it in GitHub Desktop.
Car Factory
function makeCar(brand, model) {
return {
brand,
model,
};
}
const makeToyota = makeCar.bind(null, 'Toyota');
const makeVolvo = makeCar.bind(null, 'Volvo');
const makeToyotaRAV4 = makeCar.bind(null, 'Toyota', 'RAV4');
var toyotaRAV4 = makeToyota('RAV4');
var volvoXC90 = makeVolvo('XC90');
var anotherToyotaRAV4 = makeToyotaRAV4();
console.log(toyotaRAV4);
console.log(volvoXC90);
console.log(anotherToyotaRAV4);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment