Tuesday, October 29, 2013

dojo/_base/lang!

If "dojo/_base/lang" is defined as "lang" then...


myArray.forEach(lang.hitch(this, function(itemInMyArray) {
   alert(this.whatever + itemInMyArray);
}));

 
 

...inserts the scope of "this" from outside of the function into the function in a manner that is more or less equal to something like so:

var self = this;
myArray.forEach(function(itemInMyArray) {
   alert(self.whatever + itemInMyArray);
});

No comments:

Post a Comment