All Posts assertfail

View the Blog on GitHub wallymathieu


08 Apr 2009

I’ve come to admire the simplicity and style of jquery. There are some cons to it’s approach of using context (as can be seen as this in the for instance “each”):

jQuery("#table tr").each(function(){

This wreaks havoc with some object oriented programming techniques:

var classSmurf = function(){ = "smurfette";
    this.SmurfAround = function(){ alert("Smurf: "; }

This is a simplified example that is broken by jquery’s use of context. There is a simple work around for this:

var classSmurf = function(){ = "smurfette";
    var that = this;
    this.SmurfAround = function(){ alert("Smurf: "; }

But don’t take me wrong. I love jquery. It’s really easy to use. A designer (with some css and html knowledge) can learn how to use it. That shows how easy it is to work with.


  • javascript
  • jquery
  • Comments or errors? Fork post and do a pull request on github