I decided to write this post, because I revised a Javascript code realized by a colleague and it was simply terrifying!
It was bad formatted, it had HTML style comments (<!- – - ->) with insignificant or unclear content, missing var declarations and so on.
What I would like to say is that, in order to use jQuery and similar js libraries a mere HTML knowledge is not enough, Javascript is not hard to understand and use as Java, C++ or other object oriented programming languages are, but several things must be clear before to write some code. If you want to use in a clever and productive way such libraries you should at least:

  • Understand the difference and behavior of String, Number, Array, Date and so on
  • Have a deep understanding of what DOM is and how it works (you should at least know these methods: getElementbyId(), getElementsByTagName(), createElement(), appendChild(), removeChild() and innerHTML property)
  • Know what objects and constructors are and how they behave
  • Know what a function is and how to create one
  • Know events, event listeners and event handlers
  • Understand loops

Too much stuff to learn? It’s the minimum to know, there are then prototyping, JSON, closures, XMLHttpRequest and so on…
Javascript is a programming language (not a tool for designers), don’t believe that a call to $.doMagic() will resolve your problems, you have to understand what is behind that doMagic() (at least the foundations) in order to realize concrete stuff… otherwise you will only write “magic spaghetti code”!