One of the worst pieces of advice that I have ever received was from an architect / team leader which I used to work with. He told me,
“Don’t waste your time learning Javascript. Just learn one of the modern libraries like jQuery.”
As you can probably figure out, this guy was a bad advice machine, with terrible judgment to boot.
In a Douglas Crockford video I once watched, he lamented that one of the big problems which plagued Javascript was that developers started writing it without actually learning it first. As I trust the great Douglas Crockford over the aforementioned incompetent architect, I decided to learn Javascript.
The reason I bring this up is because the other day I was reading the jQuery API documentation about the map() function (refreshing my memory – it had been a while). In the examples section, the following code was set out:
... <script type="text/javascript">// <![CDATA[ $.fn.equalizeHeights = function() { var maxHeight = this.map(function(i,e) { return $(e).height(); }).get(); return this.height( Math.max.apply(this, maxHeight) ); }; $('input').click(function(){ $('div').equalizeHeights(); }); // ]]></script>
If I was not fluent in javascript, I would not have understood the following fragment of code:
Math.max.apply(this, maxHeight)
The apply method is quite particular to javascript. Sure, I could have Googled that code and just chucked it in my project to get it working. But I wouldn’t have a clue why it works. And many developers I know aren’t even aware of the apply method, let alone what it does. Don’t be surprised by that. Really!
As it turned out, the architect I mentioned above did not understand Javascript or AJAX at all. This became apparent in various team discussions, and made for some great giggling amongst the junior developers.
So listen to Crockford. Learn Javascript! With the HTML 5 stuff and the advent of client-side, data-binding frameworks, developers will be writing more Javascript than they ever have before.