68
rated 0 times
[
73]
[
5]
/ answers: 1 / hits: 38372
/ 10 Years ago, wed, april 2, 2014, 12:00:00
What's the modern and correct way to pass the this
context to an anonymous forEach function?
function Chart() {
this.draw = function(data) {
data.forEach(function(value) {
//do something with values
console.log(this); //question: how to get Chart instead of global scope?
)};
});
};
More From » foreach