Thursday, August 14th, 2008
Secrets of the JavaScript Ninja: A sneak peak for Ajaxians
John Resig is working on the Secrets of the JavaScript Ninja book, which I am sure will be a success.
Manning has been kind enough to give us a sneak peak at some of the chapters:
This content introduces the closure, an important aspect of JavaScript, and describes its use. It goes into detail on making private data, and dealing with callbacks and timers.
Next up introduces the construct (function(){})() and describes its use in relationship to closures. See how you can create encapsulated temporary scopes.
This section introduces the technique of instantiating a function to give its prototype property functionality.
And finally we are introduced to the technique of emulating classical-style inheritance in JavaScript.












FireFox 3 opens a new tab and throws a bunch of JS errors when I click on these links, but thats it.
the links to the pdf-files just lead me back to the article. how do i get to the files?
Just FYI: These articles haven’t gone through any sort of editorial control at this point so there’s bound to be spelling mistakes, code mistakes, etc. I’m frequently making revisions and posting the current copies up on the Manning site. http://manning.com/resig/
Hum, I think that would be a samurai on the cover.
I’m having the same issues others are with the PDFs—the links don’t seem to be working at all.
And I agree with “SamoriGorse”… That’s a samurai on the cover, not a ninja. And yes, there IS a big difference.
At least it’s not a pirate. ;-)
(in regards to the samurai) While I do feel that it is a very nice cover I completely agree that it is not a ninja (or, at least, not the traditional hollywood ninja). I provided an alternative ninja for the cover, found on the book’s web site: http://jsninja.com/ but Manning opted not to use it. Maybe some fuss might sway their minds.
Waiting for the book to released and I know it would be the best book ever on JS. But I wish I can have those pdf’s now :-)
I’m having the same PDF link issues here; the links just redisplay this page. FF3 Mac.
Figured it out - you just have to replace the plus in the url with a “%20″ (without quotes). This gets it to work for S3Mac
The links are incorrect, just replace the “+” with a ” “
Just had a quick look at the closures… looks good, no major hickups… however I’m missing one bit that should probably go into the closures chapter: Creating wrapper functions which call a given method in the correct scope… it’s really essential to working with event listeners and solves many problems, especially for former Java developers.
@Hans Schmucker: That’s covered in the full chapter - what’s shown above is just an excerpt of the introduction.
@JohnResig The alternative “ninja” that you provided is MUCH better.
Does anyone from Ajaxian actually read the comments?
The links work fine in IE6.
Hahaha… ”The links work fine in IE6″. Sorry, that was funny.
Anyway, there is something “wrong” with the links, the href attributes only point to “www.…” instead of “http://www.…” which, in my browser (Safari 3.1.2 on the Mac) just puts the “www.…” as the last part of the path (so it tries to send me to “http://ajaxian.com/archives/www.manning.com/resig” for example).
Then you can add magic-turning-of-plussign-into-spacesto the list of IE 6 bugs.
Also experiencing the “+” problem in Safari 3.1.2 on Mac.
Exchanging it for a space, which gets converted to “%20″, does the trick!
Object.subclass is wreaking havoc on my brain.
I changed the links to not have a space in there and it should work better now for all. Sorry about that!
looks hot, and sounds like a must for my book shelf.
Dying to get this book. When is it coming out?!
@all: I’m about halfway done with the book at this point - we’ll have to see how long the next half takes (the next chapters, theoretically, should be easier to write). The final book probably won’t be out until this winter - hopefully in time for Christmas.
With John Resig and Douglas Crockford there are good literature about javascript :)
John just had a peek at the prototype chapter. It looks great. I’ve been waiting for your new book since you posted that your doing a new book on your site. Cant wait to get your book on my bookshelf too.
Dude, release the book already. I just read the function one, it’s fantastic!
Great preview, though my boss was upset at the lack of ninja on the cover, as it seems many other people are as well. =p
On a pet-peeve/pedantic note …
PEEK, the word is PEEK not PEAK.
Other than that recurring and annoying word misuse, love the site etc.
For me a Ninja has always been a turtle. Since I’m told I’m wrong, I went to Wikipedia, and what did I find in the dress section:
“There is no evidence historical ninja wore all-black suits. In modern times, camouflage based upon dark colors such as dark red and dark blue is known to give better concealment at night. Some cloaks may have been reversible: dark colored on the outside for concealment during the night, and white colored on the inside for concealment in the snow. Some ninja may have worn the same armor or clothing as samurai or Japanese peasants.”
This encourages me to stick with the Samurai guy riding a wave–after all, he ’s got to be pretty crafty if he’s able to do that.