I bought this book hoping to get a gentle introduction to the ubiquitous programming language, Javascript. Being at the 8th edition, it seemed that this book has stood the test of time and were a good choice for an aspiring web developer with no technical background. Actually, I had a bad feeling about this book, when after 5 pages I read the following advice from the authors: "Don't type that code[...] It was tough enough for us to do all the that typing, and there's no reason you should have to repeat that work." Compare this, with the recommandation of another author, Larry Ullman: "I strongly encourage you to type the scripts yourself in order to become more familiar with the structure and syntax of PHP".
The main reason I took a dislike to this book is because it's a tutorial-based text with insufficient explanatory details for understanding the example script code. The examples are unnecessary difficult to comprehend for a beginner because the theory behind the topics being presented, is meager. I was constantly refering to other resources in order to understand the logic behind the code scripts. I'll present an example of this, so you can judge if my complain is justified or not:
Chapter 9, Cookies in JS, says that a cookie is a text string with the following format: cookieName=cookieValue;expires=expirationDateGMT;path=URLpath;domain=siteDomain. Then, a function, setCookie(), is set to construct a cookie, and among other lines, it contains the line: document.cookie = "userName=" + username + ";expires=" + expireDate.toGMTString();
After this, the authors write a function that reads and displays the cookies, with the following lines:
var thisCookie = document.cookie.split(";");
for (var i=0; i<thisCookie.length; i++) {
outMsg += "Cookie name " + thisCookie[i].split("=")[0];
outMsg += "Cookie value " + thisCookie[i].split("=")[1];
}
For a cookie set, for example, to "ppkcookie1=testcookie; expires=Thu, 2 Aug 2012 20:47:11 UTC", I was wondering for many minutes why the code would display only "Cookie name ppkcookie1 Cookie value testcookie", and would not the display the part with the expiration date that was a part of the original string.
Luckily, I found the explanation for this apparently unexplainable behaviour of this string, in a site about JS: "Cookies can be created, read and erased by JavaScript. They are accessible through the property document.cookie. Though you can treat document.cookie as if it's a string, it isn't really, and you have only access to the name-value pairs". If this information was available in the text, I would have understood at first hand, why only the name-value pairs were accessable from the document.cookie.
In conclusion, will one learn some JS by reading this book? This book will teach you some JS, but it is necessary to consult other sources in order to keep up with the code examples: unfortunately all the authors do, is tell you what to do, instead teaching the language.