I’ve been slowly working on a new JavaScript book that covers many of the specifics behind how and why JavaScript libraries are designed they way that they are – titled Secrets of the JavaScript Ninja. I’m still working on the book – I have four chapters left to write – and am hoping to have it completed this year.
Incidentally Manning Publishing is running a special (today only!) offering the ebook version of Secrets of the JavaScript Ninja for 50% off the normal price, if you use the coupon code pop0901. (Note: I’ve heard that it may also work for the ebook + paperback version of the book.)
A number of excerpts from the book can be found in the site archive. My Learning Advanced JavaScript interactive tutorial is also based upon the contents of the book.
Note: The book is not yet complete, nor has it gone through any proofreading or technical editing – there will be mistakes. Also, yes, I’m aware that the cover of the book has a samurai on it, not a ninja – I’m working with the publisher to rectify this.
I’ve also been asked if people should buy Pro JavaScript Techniques (my Apress book from 2006) or my upcoming one. I should note that the upcoming one is much more advanced than my previous one – covering much more complicated topics and more about cross-browser development. If you’re looking for a good introductory book to JavaScript and the DOM I strongly recommend Nicholas Zakas’ Professional JavaScript Developers book.
Marc Grabanski (September 1, 2009 at 2:56 pm)
I successfully ordered the, “ebook + paperback version” with the discount! Though it didn’t work for me the first time I tried.
John Anderson (September 1, 2009 at 3:38 pm)
I was also able to order the ebook + paperback edition with the discount. Thanks, John!
Amin (September 1, 2009 at 3:38 pm)
me too!
Evan Larsen (September 1, 2009 at 3:53 pm)
I was able to get the discount on both the ebook and paperback edition. When the final version comes out will I be able to get that in pdf version? or will I have to re-order it again?
I hope this book teaches me some of your ninja secrets :P
John Resig (September 1, 2009 at 3:54 pm)
@Evan Larsen: I suspect that you’ll get a PDF as well (I sure hope so – it’d be lame if that’s not the case).
ricardoe (September 1, 2009 at 4:05 pm)
Yeah! Thanks John.
Great deal.
Christian Zambrano (September 1, 2009 at 4:12 pm)
Thanks John. Awesome deal. I sure hope I get another pdf once the book if finished.
Andrei Medina (September 1, 2009 at 4:13 pm)
Ah, too bad. I am more of a Javascript Ronin, so I guess I go and try that Nicholas Zakas book.
Jose Cortinas (September 1, 2009 at 4:56 pm)
I ordered the PDF version like 6 months ago and have been following your early updates, great book John.
John Resig (September 1, 2009 at 4:58 pm)
Note to all: If for some reason Manning doesn’t give you a final PDF of the book, but you ordered the MEAP, email me and I’ll make sure you get one.
Daniel O'Brien (September 1, 2009 at 6:19 pm)
Another successful order of ebook + paperback here. Thanks for posting the discount! Now to hurriedly tell my friends before it expires. :)
Peter (September 1, 2009 at 6:49 pm)
Got one!
Thanks a lot for the code :)
Nicholas C. Zakas (September 1, 2009 at 7:19 pm)
Thanks for the recommendation, John. I’m looking forward to your book, as well!
Mike T. (September 1, 2009 at 7:38 pm)
The real secret is that the Samurai on the cover is a Ninja in disguise. :)
Thanks for the discount–ordered!
Tang Biao (September 1, 2009 at 8:59 pm)
Thanks, John. Got one.
Marcel (September 1, 2009 at 9:02 pm)
Just purchased my first ever e-book, perhaps a little cause you used Ninja in the title and I love Jyujitsu in any form, but mostly as I can’t wait till the day there’s a solid server-side javascript standard so I can convince companies to install Jaxer or similar. I think if all server side technologies (Coldfusion, php, ruby, .Net etc…) had a compatible server-side javascript implementation it would be my perfect world…
John Meyers (September 1, 2009 at 9:27 pm)
I just ordered a copy. And I also found out that the discount is across the board (or at least for the other MEAP title I ordered). Thanks John!
Mark (September 1, 2009 at 9:46 pm)
http://www.tjoos.com/Coupon/76855/Manning-Publications
Ordered a copy since we use javascript heavily at tjoos. Also works for the print copy (got $20 off)
Greg Ferrell (September 1, 2009 at 10:27 pm)
Just ordered a print version for 50% off. Thanks a ton man!
Can’t wait for the print version for some park bench reading :).
Alex Barberis (September 1, 2009 at 11:14 pm)
Just ordered a print copy, thanks for the heads up.
Sal (September 2, 2009 at 12:05 am)
Just placed an order as well. Thanks John.
Thomas (September 2, 2009 at 12:45 am)
Yus, got my own copy, too. :)
Shipping costs a crazy to Germany, but it’s well spent, I think.
Klemen Slavi? (September 2, 2009 at 12:59 am)
Excellent, been wondering how far along the book was. Ordered both for good measure. :)
Sebastian Werner (September 2, 2009 at 12:59 am)
Just ordered the ebook edition. Thanks for the hint. It’s just 9 euros. Very cool!
Joel Overbeck (September 2, 2009 at 1:24 am)
Got your book with the discount, loving it so far. You deserve every support you can get. jQuery saved me a lot of headaches at work.
Ryan day (September 2, 2009 at 1:41 am)
hey john, like everyone else i wanted to thank you for the heads up on the book discount i bought mine about 30 seconds after i found out =).
I noticed that you refer to the super examples in your learning advanced javascript slides
on http://ejohn.org/apps/learn/#45 i wanted to note
the Array object also always returns an array and accepts n arguments
var makeArray = function(array){Array.slice.call(array)};
can change to
var makeArray = function(array){Array.apply(Array,array)}
yours is smaller i just thought the option might inspire someone =)
sunswordrie (September 2, 2009 at 1:45 am)
To me too)
Tuzemec (September 2, 2009 at 3:30 am)
Thanx, John!
Already ordered :-)
lyricnz (September 2, 2009 at 4:30 am)
Thanks for the tip. Purchased.
skillet-thief (September 2, 2009 at 6:09 am)
Great, just purchased the PDF by itself. (.epub would have been nice too.) Thanks, looking forward to reading this.
mikro (September 2, 2009 at 7:25 am)
Just ordered mine too (PDF + paperback) to Poland :-)
Thanks for info
William Apken (September 2, 2009 at 8:10 am)
Just ordered your book last night. Was up to 3am reading, could not put it down. Or walk away from the screen. I have to admit some of it is over my head. But, I can see the power that it offers. I’m glad I got it in digital form. It is going to be one of those books that the pages are falling out because you refer to it so many times. One quick question. Would I be using the language incorrectly to try and create a class that contains collections of classes. I have been using C# and VB for a while and my brain is conditioned to break projects down into classes. Or should I try to “forget” that way of thinking and approach js differently.
The few site that I have created use ajax a lot to load pages dynamically. I want a postbackless world. That God and you for the .live() method.
Thanks for all you have done for js and keep up the great work.
William Apken
Timothy (September 2, 2009 at 8:14 am)
Awesome. Ordered.
Thanks, Resig
Eron (September 2, 2009 at 12:18 pm)
Ordered a copy of the book. Thank you for letting us know about the limited-time sale. I look forward to reading more as you get closer to completing the book.
Jason Kuhn (September 2, 2009 at 12:37 pm)
i have a good day when i get an email from manning notifying me of an update to this book! it’s such an informative read.
@john i asked through twitter, tho i am not sure you received it… will you be covering mutation events in the book? in addition, will we see some sort of support within jquery; even if just hooks within the domManip methods?
Brian Racer (September 2, 2009 at 1:08 pm)
Great deal, ordered print + eBook
Yann (September 2, 2009 at 5:47 pm)
Hi Mr Resig,
I’m really waiting for your new book !
I’m sure it’ll be definitely awesome.
I noticed you provided informations about someone
else’s book; that’s nice and…humble!
Special thanks for jQuery: that was my
starting point to js, which is now more than
a language for me :)
kind regards,
Yann
yiminghe (September 2, 2009 at 8:43 pm)
This ninja book is so good that i can not wait to complete the reading of its draft version …..
Hope there will be a chinese version after its publishment , i will definitely support .
thank you
Steven (September 2, 2009 at 9:26 pm)
Thanks for the code
just order one
waited for the book for sooooo long
will keep waiting
actually for a while i thought the book was gone because haven’t seen any update for a long time
Arnab C (September 3, 2009 at 12:34 am)
John, I liked your new book, I have read the few chapters, and you have written it really good, the Timers part was a really exciting one, I never knew all of these, anyway I also read your previous book and after reading this one, one thing I have noticed and that is your writing style has substantially improved, and you are becoming a very good author, the information you presented here are more organized and compact than that of your previous book, ya I can understand that your previous attempt was your first one, during this period I think your blogging habit has contributed a lot in your writing style. I am a avid reader of your blog for sometime, can’t wait for the final release of the book. Lastly, thanks for writing this great book.
Cheers…you just rock man
Jason Cooper (September 3, 2009 at 10:18 am)
Thanks John for the discount on both versions.
Sometimes I wonder if you realize how important your work is.
I really believe jQuery (+ UI and plugins) is the new browser development standard that will be with us for so many years to come.
Thanks for staying focused and dedicated to your work.
Cheers,
Jason
Sucell (September 4, 2009 at 6:35 am)
The coupon code you have entered has expired.
:(
Julian (September 4, 2009 at 2:08 pm)
I bought the MEAP last year or so, and am looking forward to the remaining portions! Thanks for writing it.
David Parker (September 5, 2009 at 7:39 pm)
Ordered this a few days ago (with the 50% off, MEAP+dead tree) and wow… this stuff is deep. Thanks for the advanced JS and not holding back John!
Addy Osmani (September 5, 2009 at 11:26 pm)
Loved your eBook John. I’ve been recommending it to all my readers and have even included it in this month’s wrap-up of my Book selections for developers.
September’s Book Recommendations for the JavaScript Ninja or PHP Guru
filmy online (September 6, 2009 at 3:02 pm)
http://www.tjoos.com/Coupon/76855/Manning-Publications
Ordered a copy since we use javascript heavily at tjoos. Also works for the print copy (got $20 off)
Kate (September 6, 2009 at 8:48 pm)
I was one of the people to miss the 50% deal, but there’s still a general 36% off coupon code “ug367” you can use. It worked for the eBook for me, and I’d imagine it would work for the print + eBook as well.
Justin (September 8, 2009 at 9:54 am)
Doh! I ordered the early access for it last year :)
I’m more than happy to pay for it though. It’s been a great read so far.
jal (September 9, 2009 at 5:54 am)
hi,
greetings from france,
I’ve really waited for pro ressources on javascript and never found in french so i think buy your last book as soon as possible, I hope next one will be more complete :)
filmy online (September 13, 2009 at 10:17 am)
Didn’t know about it. Thank you.
Croni (September 28, 2009 at 3:11 pm)
Thank you. I’m sure it’ll be definitely awesome.
Rdewit (September 28, 2009 at 5:11 pm)
For anybody that missed out on last time’s 50% discount, Mannings has another coupon code for *any* purchase with 50% off the price:
pop0928
(expires 12 midnight Eastern Time (GMT -5) September 30, 2009).
Have fun!
beta (October 19, 2009 at 12:21 am)
Really want to be able to quickly see the book
senthil (October 19, 2009 at 3:23 pm)
I was not able to buy the book.Can someone help??
The coupon code you have entered has expired.
nicerobot (October 27, 2009 at 8:39 am)
Re: Learning Advanced JavaScript
1. Slide #38 can also be generalized as:
function User(first, last){
if ( !(this instanceof arguments.callee) )
return new arguments.callee(first,last);
this.name = first + " " + last;
Though the benefit is questionable.
2. Slide #65’s and #67’s last line(s) shouldn’t call the function?
assert( ninjaB.swingSword, "Method exists and is callable." );
instead of
assert( ninjaB.swingSword(), "Method exists and is callable." );
3. Slide #67’s title is long enough to reveal that the title doesn’t wrap before the buttons. If the title is just long enough to not wrap, the buttons occlude some of the text.
4. Slide #69’s first assert doesn’t seem to test what the message claims. If swing() doesn’t exist, the assert doesn’t fail, the statement fails. Returning true (actually anything other than null or undefined) from swing, regardless of the value of this.swung, will also pass the assert even though it’s not passing for the reasons it claims.
assert( ninjaA.swing && ninjaA.swing() instanceof Ninja, "Verify that the swing method exists and returns an instance.");
Meder Omuraliev (November 21, 2009 at 8:43 am)
pop0928 and pop0921 (50% off ) have expired, n2442 seems to work for 42% off and will expire by Nov 24.09 – there might also be another one available and it looks like the pop codes are dictated by the end date, didn’t bother checking ones for Nov and onward though.
Asen Bozhilov (November 21, 2009 at 6:11 pm)
Explanation about *closures* doesn’t haves very important things.
– How function object been associated with AO/VO at running execution context via internal [[scope]] property in different ways to create function object.
– Doesn’t have behavior of Function constructor. Section forget about functions created via Function constructor. When function been created with Function constructor, internal [[scope]] refer Global Object independent of execution context in which been called Function [[Construct]] or [[Call]]. So when been called Function constructor, we cannot forming *closure*.
– Doesn’t have Identifier resolution against scope chain. That is again important part.
– Doesn’t have explanations about disadvantages of *closures*. What will be happen with AO/VO associated with execution context in which been create *closure*, when execution context finish?
– Example with *private* again doesn’t have explanations about memory usage and how each time when called “Ninja” constructor:
function Ninja()
{
this.getSlices => create function object. assign reference to that function in property `getSlices' on created object passed from Ninja[[Construct]] as a this value.
this.slice => just like `getSlices'.
};
Activation/Variable object of "Ninja" will be referred from `getSlices' and `slice' properties and AO/VO cannot been marked for Garbage collection.
Asen Bozhilov (November 21, 2009 at 6:31 pm)
@nicerobot
“1. Slide #38 can also be generalized as:” What mean can be generalized. Generalized something with fixed length of arguments :~). If you want generalization of that *factory* method you can put one *dummy* object in prototype chain.
e.g.
function Foo()
{
if (!(this instanceof Foo))
{
var f = function(){};
f.prototype = Foo.prototype;
return Foo.apply(f = new f(), arguments), f;
}
};
That is emulation of Foo[[Construct]] but cost of that is one object much-more in prototype chain. But that is independent from arguments.length which been passed to Foo[[Call]] from caller.
Asen Bozhilov (November 21, 2009 at 7:07 pm)
#40: Using a variable number of arguments to our advantage.
Logical error.
for ( var i = 0; i
The initial value of `i' must be 1, because object doesn't need to mixing itself. Example forget about JScript {DontEnum} bug 'valueOf' and 'toString'.
What exactly mean "Temporary Scope"? In your examples definitely AO/VO isn't temporary.
junior programmer (December 15, 2009 at 4:30 pm)
i missed the promotion sale. if another one comes on please let us know thanks!
nicerobot (January 8, 2010 at 1:51 pm)
@ Asen Bozhilov
You’ll notice that the slide has this:
if ( !(this instanceof arguments.callee) )
return new User(first, last);
I simply replaced the use of
new User(...)
withnew arguments.callee(...)
> It makes it so that that code can be pasted into any constructor. With a little extra work, it can even be generalized more to manage the arguments too (maybe using .apply or standardizing argument passing as arrays) so that the code can be pasted without modification into any constructor.Chris West (January 8, 2010 at 2:46 pm)
I am sure that you have done a great job on your upcoming book. I think that one thing that is absolutely important for all JS library critics is that these libraries are for the general populace who need help quickly developing a nice looking, dynamic site without having to learn and write a great deal of JS code.
pote (July 27, 2010 at 5:13 am)
I suggest you concerned about the Chinese KongFu, Taoism