(function(value) {
this.value = value;
$('.some-elements').each(function(elt){
elt.innerHTML = this.value; // possibly undefined (Why?)
});
})(2);
Can someone explain the value of 'this' in the above code please ?
My understanding:
this.value = value // Line 2
- here this refers to the global object
elt.innerHTML = this.value; // line 4
- why is this 'possibly' undefined. Please explain.
Edit: btw I have thoroughly read the explanation for 'this' in this( How does the "this" keyword work? ) post ( from where I got the above code)