Javascript this as a parameter
This is not this object!
Javascript is really unexpected in term of object orientation, particularly for me that I come from a Java background. The least expected surprised I got from the object reference this. Consider the following jQuery each example:
list = $("ul");
[ <ul id="letters"> <li>A</li> <li>B</li> <li>C</li> </ul> ];
$("li").each(function(){ console.log( $(this).text() ) });
A
B
C
This happens thanks to jQuery, binding the this object to the item over which it iterates. For instance, if we use Underscore, we would have a … Continue Reading
