Skip to content

Instantly share code, notes, and snippets.

@Teino1978-Corp
Last active November 10, 2015 04:45
Show Gist options
  • Save Teino1978-Corp/6f33463b46dbeec6f469 to your computer and use it in GitHub Desktop.
Save Teino1978-Corp/6f33463b46dbeec6f469 to your computer and use it in GitHub Desktop.
Applying context of functions to javascript variable
var foo = {
a: function() {
alert(this.a);
},
b: function() {
this._b +=;
alert (this._b);
}
var moo = new Something(); // some object
var moo.func.foo = foo; // right now this is moo.func
var moo;
Something.prototype = foo;
moo = new Something();
moo.a();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment