Skip to content

Instantly share code, notes, and snippets.

@mkuklis
Created June 15, 2011 18:25
Show Gist options
  • Save mkuklis/1027738 to your computer and use it in GitHub Desktop.
Save mkuklis/1027738 to your computer and use it in GitHub Desktop.
JavaScript borrow method pattern
var foo1 = {
name: "hello from foo1",
print: function () {
return this.name;
}
};
var foo2 = {
name: "hello from foo2"
};
// foo2 'borrows' print from foo1
foo1.print.call(foo2); // hello from foo2
//----------
function f() {
var args = [].slice.call(arguments, 1, 3); // arguments borrow slice from Array
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment