Pro JavaScript Techniques

By John Resig

Pro JavaScript Techniques provides everything you need to know about modern JavaScript. This book focuses on fundamental, vital topics—what modern JavaScripting is (and isn't), the current state of browser support, and pitfalls to be wary of. It is organized into four distinct sections, each of which features several real-world examples.

Full Description

  • ISBN13: 978-1-59059-727-9
  • 384 Pages
  • User Level: Beginner to Advanced
  • Publication Date: December 12, 2006
  • Available eBook Formats: EPUB, MOBI, PDF
  • Print Book Price: $44.99
  • eBook Price: $31.99
Buy eBook Buy Print Book Add to Wishlist

Related Titles

Full Description

Pro JavaScript Techniques is the ultimate JavaScript book for the modern web developer. It provides everything you need to know about modern JavaScript, and shows what JavaScript can do for your web sites. This book doesn't waste any time looking at things you already know, like basic syntax and structures.

Expert web developer and author John Resig concentrates on fundamental, vital topics—what modern JavaScripting is (and isnt), the current state of browser support, and pitfalls to be wary of. The book is organized into four sections:

  • Modern JavaScript development using JavaScript the object-oriented way, creating reusable code, plus testing and debugging
  • DOM scripting updating content and styles, plus events, and effect and event libraries
  • How Ajax works, overcoming problems, and using libraries to speed up development of Ajax applications
  • The future of JavaScript looking at cutting edge topics like JSON, HTML5, and more

All concepts are backed up by real-world examples and case studies, and John provides numerous reusable functions and classes to save you time in your development. There are also up-to-date reference appendixes for the DOM, events, browser support (including IE7), and frameworks, so you can look up specific details quickly and easily.

Source Code/Downloads

Downloads are available to accompany this book.

Your operating system can likely extract zipped downloads automatically, but you may require software such as WinZip for PC, or StuffIt on a Mac.

Errata

Please Login to submit errata.

On page 37:
Numerous errors in listing 2-25.

The use of "this" is wrong in the get/set functions that the code is creating. The author seems to think that "this" refers to the User function at that point but it doesn't: function scope means that it actually refers to the global object (i.e. the DOM window), so it won't work.

The use of "properties[i]' in those set/get functions is wrong. "i" is of the User function scope, and so will remain at whatever value the function last set it. You need to lock it to the new function's scope to make it work properly.

See below link for full explanation and working code:

http://jsfiddle.net/BrownieBoy/cmpsM/

On page 37:
The code is wrong.

in the "for" loop, you execute a function on every iteration. and in that function, you use "this".
The context of this function isn't the object and as a result it refers to the global or window object and assigns the getname property to window.

Looks like you used a function, to circumvent Closure, but it doesn't work.
MY interest is to solve this problem which closure is causing so the value of "i" is maintained and we have relevant values for getname and getage.

On page 37:
Listing 2-25 getname and getage appear to be applied to the window object instead of the user object

On page 62:

I believe there's a problem with this code, used for the 'uber' function in page 62, chapter 3;

// If we're already within another 'uber' function if (depth) {
// Go the necessary depth to find the orignal prototype for ( var i = d; i > 0; i += 1 ) {
v = v.constructor.prototype;
}

It seems that there is no 'd' variable. Perhaps the 'depth' variable should have been used instead? in that case, the for loop conditions need to be changed into var i = depth; i < depth; i+= 1

On page 132:

Listing 6-17.
1st line

var li = document.getElementsByTagName("a");
->
var a = document.getElementsByTagName("a");

On page 152:

in listing 7-13 the source code line:
elem,.style.height = (pos/100)*h) + "px";
doesn't work.