A fantastic read, and two great things brought up are the
constructor property of a variable to see what type it is (more solid than
typeof), and the
apply methods. I’ve actually missed out on the latter methods, but they are superb for setting context for a function/event.
John then explains AJAX in a good way, and then he presents three use cases:
- Enhancing blogs with AJAX
- Autocomplete search
- An AJAX Wiki
I liked the one about auto-completing search, since it’s exactly what we see in all the fancy web-apps out there, while the other two were, frankly, kind of uninteresting. I would’ve preferred more “real” scenarios that web developers come across every day, than two cases, albeit technically challenging, who weren’t that interesting from a business and end user perspective. Maybe sometimes the use cases focuses too much on the goal, and not the way to get there.
I think I would’ve preferred him delving into the depths of jQuery; what obstacles he has come across, which interesting design decisions he has made etc. After all, I think the people reading this book are more prone (and hungry) to be creating their own libraries, as opposed to using existing ones. However, I guess some people would just see the book as jQuery pimping then, so I can understand why it is mentioned so sparsely.
Other people’s code
The book mentions and displays a fair amount of code from other people, where Douglas Crockford‘s and especially Dean Edwards‘ work is prominently featured. My stand on this swayed a little; sometimes I felt that maybe I instead should’ve read a book from one of those gentlemen, while at other times, I thought John did what was the right thing to do: showing and mentioning the best code out there.
In the end, though, I’m happy to see the best code and solution out there, no matter whose name is on it.
Pick it up, if you dare! 🙂
Funnily enough my copy arrived from Amazon this morning.
My copy of this arrived last evening, and I had the same initial thoughts you did in that I thought it was great that the second paragraph began talking about Object Oriented JS. No frilly stuff from the beginning, this book dives right in.
Interesting, will have to have a look at it some time.
I can't help but swear by PKK and his quicksmode.org website – whenever I'm in doubt about anything to do with js, it's my first place of call.
Can you give a little more detail on how the book suggests to use the <code>constructor</code> property?
I'd guess you always need a null-check for <code>null</code> and <code>undefined</code> values; and I'd expect <code>instanceof</code> may be better in some circumstances?
Nice. I wish you a pleasant read!
Interesting, thanks for the link.
I'm glad that you liked the review! 🙂
The book definitely isn't biased for any specific library, I can tell you that much.
Absolutely, PPK and his quirksmode is an invaluable resource.
It is in situations where <code>typeof</code> would just return <code>"object"</code>, as opposed to <code>constructor</code> that would return <code>String</code> for a string and <code>Array</code> for an array.
I'd say that it is basically used in the same way as <code>instanceof</code>.