Reading Javascript & jQuery: The Missing Manuals was influential in several ways:

(1) The book got me through the basics of javascript and its tutorials quickly got me using jQuery to do stuff.
(2) Suddenly I knew exactly how components on under websites slid from place to place, faded in and out, and did a lot of other neat tricks. I was startled by how simple jQuery was — I wasn’t really writing code; I was accessing a javascript library and creating standard structures to pull in the hard work that other authors had done.

Then I attempted to do a simple .show() and .hide() (translation: hiding an element, then showing it upon a click) today with jQuery, and it didn’t work. Asked a co-worker who’s an experienced web developer, and he suggested I start using a debugger of some sort. He kindly linked me to Chrome Developer Tools, which showed me that there was a syntax error in the javascript.

What, you might ask, is a syntax error?

I did some googling, and some asking, and apparently the majority of syntax errors have to do with punctuation — such as forgetting to close a line with a semicolon, or forgetting parentheses.

I stared at the code. Stared some more. Then I finally had the bright idea to compare my code with another example of jquery that was working (I used this), and that was where I immediately saw that I was missing an entire set of closing parentheses });.

Whoops! Guess that I means I need to reread my book. Or just start practicing with some more examples.

My co-worker also pointed out the console.log(“comment about what your javascript is supposed to be doing here”) trick, which is achieved by putting that line above every piece of javascript you want to test, opening up browser tools, and then seeing if the line you typed runs in the browser console. He told me that it’s a good idea to get rid of these lines when the code goes live, though, because of compatibility issues with IE9.

Hurrah for super-helpful co-workers! Sometimes it’s good to have mentors who know their stuff. And to cross-check code with a working example rather than staring at it blindly, of course.

</span>

blog comments powered by Disqus
  • Hi, I'm Linda! I enjoy going to tech meetups, learning web development, and blogging about the learning path. Follow me @LPnotes

Subscribe to The Coding Diaries