Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
javascript implementation of Ruby 1.9's tap
Object.defineProperty(Object.prototype, 'tap', {
value: function(fun){
fun.call( this );
return this;
},
enumerable: false
});
// Usage:
// a = [];
// a.tap(function(){ this.push('foo'); });
// a => [ 'foo' ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.