Skip to content

Instantly share code, notes, and snippets.

@jaggy
Last active February 24, 2016 09:03
Show Gist options
  • Select an option

  • Save jaggy/75720a5d15410955fb9f to your computer and use it in GitHub Desktop.

Select an option

Save jaggy/75720a5d15410955fb9f to your computer and use it in GitHub Desktop.
var personCurry = function (name) {
return function (greeting) {
return function (person) {
console.log(greeting + ', ' + person + '! My name is ' + name);
}
}
};
var jaggy = personCurry('Jaggy');
var greet = jaggy('Hi');
greet('Martin');
class Person {
constructor(name, greeting = 'Hi') {
this.name = name;
this.greeting = greeting;
}
getName () {
return this.name;
}
greet (person) {
console.log(`${this.greeting}, ${person.getName()}! My name is ${this.name}`);
}
}
var jaggy = new Person('Jaggy');
var martin = new Person('Martin');
jaggy.greet(martin); // Hi, Martin! My name is Jaggy
var Person = function (name, greeting) {
this.greeting = greeting || 'Hi';
this.name = name;
};
Person.prototype.getName = function () {
return this.name;
};
Person.prototype.greeting = function (person) {
console.log(this.greeting + ', ' + person.getName() + '! My name is ' + this.name);
};
var jaggy = new Person('Jaggy');
var martin = new Person('Martin');
jaggy.greet(martin); // Hi, Martin! My name is Jaggy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment