Advertisement
Guest User

Untitled

a guest
Dec 18th, 2014
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SomeClass.prototype = {
  2.     someMethod: function() {
  3.         var somevar = 1;
  4.         var self = this;    
  5.  
  6.         someOtherFuncThatWantsACallback(123, function callback() {
  7.             // in this scope we can access somevar even though it's outside
  8.             alert(somevar);
  9.             // but if we want to access "this" from the class, we need to use the "self" alias
  10.         });
  11.  
  12.     }
  13. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement