Created
May 17, 2016 00:33
-
-
Save andredublin/2cecc8f03795819f7507658bd612d0d6 to your computer and use it in GitHub Desktop.
self mapping object
This file contains 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) { | |
this.name = name; | |
} | |
// ('a -> 'b -> Person<'b>) | |
Person.prototype.map = function (f) { | |
return new Person(f(this)); | |
} | |
var me = new Person("Andre"); | |
me.map(function(x) { return x.name + "!" }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment