JavaScript : The Definitive Guide, 4th Edition
The Book in a Nutshell
Although much of the core of the language, addressed in Part I, has changed relatively little since JS:TDG3, Flanagan has added coverage of new issues that have emerged in the past several years, like the discussion of ASCII, Latin-1, and 16-bit Unicode in the beginning of Chapter 2 (ECMA-262 Edition 1, the spec that defined ECMAScript, included Unicode support for il8n purposes, so ECMAScript compliance requires Unicode support), and pruned away quite a bit of material related to NS 4.x-proprietary features, like the explanation of import and export (previously found in Chapter 6), that are naturally of increasingly less interest to developers as that line of browsers recedes into history. Much of Part II, which considers client-side JavaScript and DOM in all its glory, is entirely new or has been completely re-written. Where the chapter on the Document Object model in the 3rd edition only covered the "Level 0" DOM (the objects, properties, and methods first exposed by the 4.0 browsers), JS:TDG4 tackles the Level 0 DOM and the W3C DOM Recommendations through level 1 Core and HTML and touches on some DOM Level 2 topics, including the Range and Traversal APIs. "Cascading Style Sheets and Dynamic HTML" and "Events and Event Handling" are two other chapters in the Client-Side JavaScript section that have really come into their own in this edition.
The large (more than 300 pages), but somewhat muddled "JavaScript Reference" in the 3rd edition (it had commingled the objects, properties, and methods included in the core of the JavaScript language with those of the Level 0 DOM) has been split into 4 discrete appendices ("Core JavaScript Reference", "Client-Side JavaScript Reference", "W3C DOM Reference", and "Class, Property, Method, and Event Handler Index") that, taken together, comprise more than 400 more pages of information. NS 4.x fans can take comfort from the fact that, while much NS 4.x-specific information has been culled from the body of the text, Netscape 4.x still shows up in some screen captures (along with Microsoft Internet Explorer and Netscape 6).
What was GreatException handling (using throw and try/catch/finally) is covered in greater detail. In Chapter 15, "Forms and Form Elements", JavaScript interactions with buttons, toggle buttons (checkbox and radio elements), text fields, hidden elements, and fieldset elements are addressed individually in new sections not present in the corresponding chapter in JS:TDG3 and the section on select and option elements goes into more detail than in the previous edition. Throughout the book, improvements have been made to figures and tables - like the addition of the "Supported by" column in Table 19-1 : "Event handlers and the HTML elements that support them", which now helpfully lists the elements for which the event handlers can be triggered after identifiers for the versions of Netscape and Internet Explorer in which the behavior is observed. Finally, the book as a whole is significantly more readable. The type used for the text of the code examples and tables was too "light" in the 3rd edition (at least in my copy), and I was glad to see that it's a bit heavier in the 4th.
What was Not so Great
I nearly came up empty-handed in my search for defects in this book, but noticed that, in tables 11-1 and 11-3, "Automatic data type conversions" and "Data type manipulation in JavaScript" respectively, information relating to the treatment of arrays and functions present in the corresponding tables in the 3rd edition has been removed. That's really my only gripe. Some might wish that Flanagan had included more compatibility information, but, realistically, the task of fully documenting the intricacies of what's supported by which browser (or, in the case of Win MSIE, which JScript dll is installed) could probably fill a separate book all of its own. Moreover, Chapter 20 ("Compatibility Techniques"), may be brief at only 11 pages, but it does a good job of tackling best practices in dealing with JavaScript and DOM cross-browser compatibility challenges.
To Buy or Not to Buy
If you're in the market for a good JavaScript (or JavaScript+DOM) book, then JavaScript : The Definitive Guide should undoubtedly be your first choice. Although my 3rd edition was so tattered from long use that I really had no choice but to upgrade, even owners of the 3rd edition who've managed to keep their copies in near-mint condition will probably still want to get their hands on the 4th edition if they haven't already done so - for the meatier and updated reference appendices if for no other reason.
Table of Contents
Preface
- Chapter 1. Introduction to JavaScript
Part I : Core JavaScript
- Chapter 2. Lexical Structure
- Chapter 3. Data Types and Values
- Chapter 4. Variables
- Chapter 5. Expressions and Operators
- Chapter 6. Statements
- Chapter 7. Functions
- Chapter 8. Objects
- Chapter 9. Arrays
- Chapter 10. Pattern Matching with Regular Expressions
- Chapter 11. Further Topics in JavaScript
Part II : Client-Side JavaScript
- Chapter 12. JavaScript in Web Browsers
- Chapter 13. Windows and Frames
- Chapter 14. The Document Object
- Chapter 15. Forms and Form Elements
- Chapter 16. Scripting Cookies
- Chapter 17. The Document Object Model
- Chapter 18. Cascading Style Sheets and Dynamic HTML
- Chapter 19. Events and Event Handling
- Chapter 20. Compatibility Techniques
- Chapter 21. JavaScript Security
- Chapter 22. Using Java with JavaScript
Part III : Core JavaScript Reference
Part IV : Client-Side JavaScript Reference
Part V : W3C DOM Reference
Part VI : Class, Property, Method, and Event Handler Index
Index
You can purchase JavaScript: The Definitive Guide from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.
I like seeing non-IE browsers getting coverage in the mainstream technical press. IE has something like a 95% market share, and many people use this to justify making websites that only work in IE. If *I* were running a web business then that statistic would tell me:
"Hey, 1 out of 20 of our potential customers can't use our website!"
And I think that IT should be pitching that same line to the suits.
Anyway, until someone develops intellegent JS filtering that works, I just turn it off.
In Capitalist America, bank robs you!
Speaking as a web developer here -- it usually means that they've special-cased their code for IE and NS4 and the scripts they've written break on any browser which doesn't identify itself as one of those (especially as the netscape 4 test involves something to do with layers). Decent web developers write to the spec, and then and only then put in fixes for broken browsers that they know of.
Mozilla doesn't support a few DOM access methods that IE does, because they're not in the W3 specs... they use alternative methods that IE also supports, but this leads some people to say that Mozilla's scripting support is 'broken'.
(Tangentially, I was reading on Bugzilla about some performance problems with Mozilla's JavaScript & DHTML, but that was more speed-related than functionality-related, I think.)
deus does not exist but if he does
Alternative title #6: How To Build Really Spiffy Web Sites That Will Work Perfectly For You And About Two Other People, Provided They Both Use Exactly The Same Browser, Operating System And Patches As You, in 22 easy chapters
--
What short sigs we have -
One hundred and twenty chars!
Too short for haiku.
I certainly do not agree with you. Web development is principly about information architecture - the HTML. That's what really, really matters. Then you can get fancy with CSS and graphics - and javscript for the really fancy or for complex applications. But like mitchener said , JS is too often used merely for flashy effects, and while those can be cool, they are in no way important to an effective website. Javascript has its place and uses - one can make some great interfaces with it if one needs to - but I don't think it's nearly as important as you say it is.
Cheers,
Karma: T-rexcellent.
It isn't being done because all of the minute differences in javascript implementations in the various browser flavours & versions on different platforms make writing truly universal code a nightmare. The only solution I've found is to stick to the most basic features that are guaranteed to work for nearly all clients. Every time I try to use more advanced features, I end up pulling my hair out for hours/days trying to make it work for all versions, and then someone *still* comes back saying it doesn't work on IE 4.5 on the Mac (or fill in your least favorite browser here).
I suppose the other thing I could do would be to detect the client when they access the page and do a code branch specifically for that browser, but that's a nightmare as well.
If I do everything on the server side, I can guarantee that it will work for everyone, since I only need to code for my app. server. Yeah, that means that I have to go back to the server sometimes when I could use JS, but it's a tradeoff I'm willing to make. Consider error checking/form validation. I could write a client side validation script for every form I produce, but doing so isn't going to get me out of doing the same thing on the server side, since users can disable javascript.
Don't get me wrong, some great things can be done with javascript, I just find the overall effort required not worth it. I'd rather spend my time writing code than endlessly running around the testing lab trying to fix the differences between Netscape 4.6 and 4.7x.
As a user the lack of standardization is a total pain in the ass as well. Last night is a perfect example - my SO couldn't view a well-known travel site through Netscape on our (admittedly aging) Mac because whoever coded the damn page had left so many script errors/incompatibilities in the page that she was effectively barred from accessing the site.
Just my humble rant.
The only problem with JavaScript is as you cite:
I've enjoyed using JavaScript for almost as long as I've been using HTML (4/5 years), and believe it can genuinely help to reduce server load (think of all those validation scripts), yet JavaScript is steadily becoming less applicable due to the ability to disable it in the client.
A lot of ordinary web users, in an effort to block pop-ups, have disabled JavaScript in their browsers, and all other applications which could easily make use of this technology suffer as a result. Personally, I couldn't blame them for this, as I find pop-ups as irritating as the next person.
Until ordinary web-users come to trust web sites not to thrust adverts down their throats using pop-ups, pop-unders or whatever, then this valuable technology will remain unusable on the vast proportion of (mainstream) web sites.
Of course, the odds of marketing-types not pressing developers to use any technology in an immoral way are extremely remote.
Variables can be declared or not, line termination is optional, it's supposed to be object-oriented but there's no way to decalare class or methods, some construct are really horrible:
value =selectBox[selectdBox.selectedIndex].value
then you also don't like perl, i take it, since all your complains apply there, as well.
while you can't declare classes as simply as you can in some other languages, you can use the javascript prototype mechanism to do the same thing; and you certainly can create constructors and methods. evidently, you need to study up on the language a bit more. the book under discussion here would be a good place to start.
JavaScript is a solid language and can be used to interesting and useful things on the web. the fact is, people abuse every language, in one way or another. no user is forced to be lazy and propagate write-only code; it's done all the time in C, C++, perl and probably any other language you would care to name.
mp
"The secret to strong security: less reliance on secrets." -- Whitfield Diffie