Reading Up On Javascript

Shortly after finishing the beta version of my Typing Speed Test I started to feel like my knowledge of Javascript had some holes in it, especially in the event handling area. It’d been a long time since I’d read a book on Javascript, so I figured I’d pick one up one to help fill in the holes in what I knew.

I looked around a little bit before selecting “ppk on Javascript”. I chose this book after reading some of the author’s online articles. They were easy to read and contained a lot of interesting tidbits. I don’t want to turn this entry into a book review, so I’ll just say I enjoyed the book and would recommend it. However, the book admittedly doesn’t cover certain topics like OOP in Javascript. Though even with its omissions, it still ended up covering a lot of ground. The major things I took away from the book were:

  • Event Bubbling vs Event Capturing – I feel bad I didn’t know about this. It answers the question: If an element and one of its ancestors have an event handler for the same event, which one fires first?
  • location.href vs location.replace – It’s best to use “replace”. This is because replace doesn’t create a new history entry in the visitor’s browser. This is a good thing, since you don’t want to make a user’s back button useless.
  • The navigator.userAgent string has an amusing story behind why its value is so convoluted.
  • getElementsByTagName – I didn’t know about this DOM function. It looks like it could be really useful though.
  • DOM Tree Text Nodes – When you create an HTML document, the text between tags and the text inside of a particular tag become text nodes. IE doesn’t support empty text nodes while other browsers do, this appears to make modifying the DOM tree a pain.

There were other things too, but those are what stick out in my head while I type this. I’m really glad I read that book. It reminded me of how useful programming books are (I had gotten too use to just Googling whatever I didn’t know).

Right now I’m a little more than 50 pages into “Pro Javascript Design Patterns”, which covers design patterns and OOP in Javascript. So far it’s really good. I had been meaning to read up on design patterns for a while so I’m pretty excited about this new book. I’m averaging almost 20 pages a night, so I should finish up pretty quickly. Once I finish, I’m going to get back to creating content for this site. I may make some posts in the meantime, but I figured I’d give you all a heads up as to what I was doing so you didn’t think I had forgotten about this site.

7 thoughts on “Reading Up On Javascript”

  1. Are either of those good for someone who wants to get started with javascript, or are they a “next level” sort of thing?

  2. “ppk on Javascript” would be really good for someone interested getting into Javascript. The author assumes you already know a little JavaScript and that you are familiar with HTML and CSS. Knowing HTML and CSS is important, but as long as you know C++ or Java, the JavaScript code he provides in the beginning is easy to follow. And chapter 5 covers JavaScript Core, which explains how every basic statement works (if’s, loops, switches, etc), so you don’t miss understanding any of the basic functionality.

    The only draw backs to the book that come to mind are:

    – It was written in 2006, so some of its information on browsers is a little dated, and it doesn’t cover any JavaScript features that have been added since then.
    – It doesn’t cover OOP in Javascript.
    – I’m not sure I agree with all of the author’s philosophies (thin client > fat client), but he mentions that there are many ways of looking at things and he doesn’t dwell on this too much.

    So far, this is probably my favorite book that I’ve read on JavaScript (I’ve read two others, but a long time ago – they were from the Visual QuickStart Guide people, they were OK, but not great).

    The “Pro JavaScript Patterns” book is so far really good, but I wouldn’t recommend it to anyone unless they already had a really good handle on JavaScript and OOP. It jumps into OOP and assumes you already know a lot of JavaScript syntax.

  3. If I need to do anything in Javascript, I won’t do it without jQuery.

    I usually think it’s important to know how things work behind the scenes. But Javascript is one thing where I think it doesn’t matter. There are so many different implementations that all have their various problems.

    I’ve never found an actual “Standard” for javascript. I thought ECMAScript was supposed to be some form of standard, but I have no idea if any browsers support it. The DOM-model is something separate entirely and is maintained by the W3C, which means it doesn’t really mean anything. The “official” javascript is maintained by Mozilla, and they have a lot of cool features in the works for js, but how many other implementations will include them?

    Everyone says the biggest problem is IE, and it’s true. But there are plenty of incompatibilities that I’ve run in to between Opera and Firefox. Enough to make me give up on trying to write plain ol’ Javascript and let the experts who make jQuery take care of it. It saves me so many headaches.

  4. ECMAScript is also the backbone of Flash’s ActionScript.

    You’re right about different groups standardizing different parts of JavaScript. ECMA does JavaScript Core (ECMAScript) and W3C and Microsoft do everything else (DOM, event handling, CSS modification, data retrieval, etc). According to the ppk book, a group called WHAT-WG is/was doing BOM (Browser Object Model), but I couldn’t find anything on Google about it, so W3C may be doing that now too.

    I actually thought about getting a book on jQuery, and I still might. I’ve read the introductory tutorials, but I just never seem to get around to actually using it for much. If I have some extra time over Christmas I’ll pick something up on it, since browser issues are a major pain in the ass.

    However, I still think knowing JavaScript is a good idea. Knowing its ins and outs will allow me to do more than if I just knew the ins and outs of jQuery. Plus, the biggest incompatibilities seem to be in the DOM and in event handling, the JavaScript Core stuff doesn’t seem to have too many issues.

Comments are closed.