Last active
February 24, 2016 09:03
-
-
Save jaggy/75720a5d15410955fb9f to your computer and use it in GitHub Desktop.
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 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'); |
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
| 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 |
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 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