Skip to content

Instantly share code, notes, and snippets.

@mvasilkov
Created June 17, 2013 19:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mvasilkov/5799383 to your computer and use it in GitHub Desktop.
Save mvasilkov/5799383 to your computer and use it in GitHub Desktop.
Sample code for Kiril Vatev
var lib = function() {
/* lib() is the same as lib.a() */
return lib.a.apply(lib, arguments)
}
lib.a = function() {
/* do somethig, e.g. */
console.log('lib.a() called with', arguments)
/* allow chaining */
return lib
}
lib.b = function() {
/* do somethig, e.g. */
console.log('lib.b() called with', arguments)
/* allow chaining */
return lib
}
/* usage: */
lib(0).a(1).b(2)
/* this outputs: */
// lib.a() called with [0]
// lib.a() called with [1]
// lib.b() called with [2]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment