Skip to content

Instantly share code, notes, and snippets.

@elranu
Created June 2, 2014 18:09
Show Gist options
  • Save elranu/c1d142831379cf4844b1 to your computer and use it in GitHub Desktop.
Save elranu/c1d142831379cf4844b1 to your computer and use it in GitHub Desktop.
apply and call example
var x, o1, o2, r1, r2, r3;
x = 4;
o1 = {x: 2};
o2 = {x: 7};
f = function(m, n) {return m * n * this.x;};
r1 = f(3, 1));
r2 = f.call(o1,3, 1));
r3 = f.apply(o2,[3, 1]));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment