Skip to content

Instantly share code, notes, and snippets.

@potch
Created March 6, 2013 21:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save potch/5103089 to your computer and use it in GitHub Desktop.
Save potch/5103089 to your computer and use it in GitHub Desktop.
Hey I just wrote this.
// this is crazy
Function.prototype.callMeMaybe = function(ctx) {
var args = Array.prototype.slice.call(arguments,1);
if (Math.random() > .5) {
return this.apply(ctx, args);
}
};
function square(n) {
return n * n;
}
// so here's my number
square.callMeMaybe(null, 2);
@lonnen
Copy link

lonnen commented Mar 6, 2013

🚢 it!

@jlongster
Copy link

you should reduce the chance if it calling the more times callMeMaybe is called

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment