Skip to content

Instantly share code, notes, and snippets.

@mrpollo
Created June 22, 2011 23:27
Show Gist options
  • Select an option

  • Save mrpollo/1041548 to your computer and use it in GitHub Desktop.

Select an option

Save mrpollo/1041548 to your computer and use it in GitHub Desktop.
Javascript use of this in OOP
function foo(){
this.test = "hello scope";
setTimeout( function(self){ self.bar(self); }, 1000, this );
}
foo.prototype.bar = function(self){
console.log( self.test );
}
var x = new foo();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment