Skip to content

Instantly share code, notes, and snippets.

@jimmiw
Created April 26, 2010 11:10
Show Gist options
  • Save jimmiw/379208 to your computer and use it in GitHub Desktop.
Save jimmiw/379208 to your computer and use it in GitHub Desktop.
/**
* this.printout(data); cannot be called. The .each on the array removes the current scope
*/
var EachTest = Class.create({
test: function() {
var arr = Array();
arr.push("a");
arr.push("b");
arr.push("c");
arr.push("d");
arr.push("e");
arr.each(function(data) {
this.printout(data);
});
// works
/*arr.each(function(data) {
this.printout(data);
}.bind(this));*/
// works
/*arr.each(function(data) {
this.printout(data);
}, this);*/
},
printout: function(data) {
console.log(data);
}
});
var eachTest = new EachTest();
eachTest.test();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment