Created
June 14, 2011 18:54
-
-
Save mattbaker/1025583 to your computer and use it in GitHub Desktop.
Object.tap in Javascript
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
Object.prototype.tap = function(f){f.apply(this); return this;} | |
var x = {a:2}; | |
x.tap(function(){console.log(this.a)}).a = 4; //Prints 2 | |
console.assert(x.a == 4); |
Neat, what are you using it for?
…On Thu, Oct 6, 2011 at 5:43 AM, Nowhere Man < ***@***.***>wrote:
FYI, I've merged your code with another one and make a little demo at
https://gist.github.com/1267298.
To run it: You need to download the HTML gist and open it in your browser.
##
Reply to this email directly or view it on GitHub:
https://gist.github.com/1025583
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
FYI, I've merged your code with another one and make a little demo at https://gist.github.com/1267298.
To run it: You need to download the HTML gist and open it in your browser.