Skip to content

Instantly share code, notes, and snippets.

@robbenmu
Forked from cowboy/call-invo-cursion.js
Created March 18, 2016 14:01
Show Gist options
  • Save robbenmu/f6b6b367f99b95d5f0a1 to your computer and use it in GitHub Desktop.
Save robbenmu/f6b6b367f99b95d5f0a1 to your computer and use it in GitHub Desktop.
JavaScript: call invo-cursion?
// OOP
console.log( 'OHAI'.blink() );
// Call invocation
console.log( String.prototype.blink.call('OHAI') );
// $ always makes things look awesome.
var $ = Function.prototype.call;
// Very explicit call invocation
console.log( $.call(String.prototype.blink, 'OHAI') );
// Very, very explicit call invocation, ie. call invo-cursion?
console.log( $.call($,$,$,$,$,$,$,$,$,$,$,$, String.prototype.blink, 'OHAI') );
// ^^^^^^^^^^^^^^^^^^^^^^^ "bonus" calls
// You can have fun with apply invocation and _ too.
var _ = Function.prototype.apply;
// Very, very explicit apply invocation, ie. apply invo-cursion.
console.log( _.apply(_,[_,[_,[_,[_,[_,[_,[_, [ String.prototype.blink, ['OHAI'] ]]]]]]]]) );
// ^^^^^^^^^^^^^^^^^^^^^^ "bonus" applies, and fun w/brackets ^^^^^^^^
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment