Skip to content

Instantly share code, notes, and snippets.

@Sinetheta
Forked from cowboy/log.js
Created November 15, 2012 22:32
Show Gist options
  • Save Sinetheta/4081888 to your computer and use it in GitHub Desktop.
Save Sinetheta/4081888 to your computer and use it in GitHub Desktop.
JavaScript: (madness?).log()
/*
* (madness?).log()
*
* Copyright (c) 2012 Kevin Attfield
* Licensed under the MIT license.
*/
Object.prototype.log = function(){
console.log(this.valueOf());
return this;
};
// logging midstream
var foo = 'bar'.log();
whatDidThisReturn = function(){return 2;};
1 + whatDidThisReturn().log() + 3;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment