Computing Reviews
Today's Issue Hot Topics Search Browse Recommended My Account Log In
Review Help
Search
JavaScript quick syntax reference
Olsson M., Apress, New York, NY, 2015. 92 pp. Type: Book (978-1-430264-93-4)
Date Reviewed: Jan 14 2016

A good reference manual for a programming language or system is, even in these days of easy Internet searching, still well worth the price. You can scribble notes in the margins, put Post-its on the pages that have things you want to find quickly, and it doesn’t take up another browser window (or screen). Better still, the good ones are rather more reliable than the results of random Internet searches.

This book is a “quick syntax reference” for JavaScript. It consists of 70 pages with 15 chapters (so about five pages per chapter, or rather less when the final page of each chapter is blank or mostly so) covering topics ranging from “Using JavaScript” to Ajax and jQuery.

However, this is not quite the “good reference manual” as mentioned above. There is a bit of coverage of syntax and usages, but too much is missing, wrong, or misleading. To complicate matters, it isn’t entirely clear what version of JavaScript (also know as ECMAScript) the book addresses. (The back cover says it is ECMAScript 5, but then the back cover also says it covers JSON, which is not mentioned in the text; I don’t think you should believe the back cover.)

A few examples follow.

Statements in JavaScript end in semicolons, or at the end of a line, kind of. The exact rules are a bit complicated and can confound a newcomer to the language. Since the index is less than useful, it is easy to miss something and then not find it easily. Even so, with this small of a text (probably about 60 pages all told), it is not that difficult to scan through the entire text quickly. I see no mention of this syntactic rule.

The undefined type is used to indicate that a variable has no value. However, undefined can (in some circumstances and in many implementations of JavaScript) be assigned to and used as a variable. Thus, a test against undefined may or may not work as the programmer expects, depending on where and how it happens.

Functions can have names “function foo() { return 7 ; }” or be named with an assignment “foo = function() { return 7 ; }.” Is there a difference between these? The book hints that the first can be used recursively and the second not, but both syntaxes work fine recursively. (There is a difference, which is not mentioned.)

Functions can also be completely anonymous--in fact, “immediately invoked function expressions” are used quite a bit in practice. These look something like “(function (x) { return x + 7 ; })(5)” and are often used to build code that evaluates in a chosen and restricted scope. These are widely used, but go unmentioned.

Regular expressions are important in many languages and most languages have variant syntaxes. JavaScript has a specific syntax for regular expressions. This again goes unmentioned (except on the back cover).

Numbers are stored as 64-bit floating-point numbers. For most use cases in things like web pages, this is not a problem as most loops (for instance) are likely to use smallish integer values, which work about as you would expect. The author does mention that numbers are converted to 32-bit signed integers for bitwise operations, but does not point out that for larger numbers integers and floating-point values can start to diverge. That fractions are not represented exactly in many cases (so that, for instance, 0.3 is not equal to 0.1 + 0.1 + 0.1) is not mentioned.

Browser compatibility is mentioned (phew!), but there are no good examples of where browsers diverge. There is no mention of Node.js, which is server side and therefore does live in a browser (and in which things like “window” or “document”--used in multiple examples--do not work).

The author recommends using an integrated development environment (IDE), which provides ways to see what operations are possible. In particular, in the chapter on arrays, instead of an actual discussion of array capabilities, we find the suggestion “code hints in your IDE provide a list of the members available to the array object.” I agree enthusiastically. Use your IDE and leave this book on the shelf.

Reviewer:  Jeffrey Putnam Review #: CR144101 (1603-0179)
Bookmark and Share
  Featured Reviewer  
 
Object-Oriented Programming (D.1.5 )
 
 
Javascript (D.3.2 ... )
 
 
Reference (A.2 )
 
Would you recommend this review?
yes
no
Other reviews under "Object-Oriented Programming": Date
Object-oriented programming systems, languages, and applications
Paepcke A.  Object-oriented programming systems, languages, and applications,Phoenix, AZ,Oct 6-Oct 11, 1991,1991. Type: Whole Proceedings
Oct 1 1992
Object lifecycles
Shlaer S., Mellor S., Yourdon Press, Upper Saddle River, NJ, 1992. Type: Book (9780136299400)
Apr 1 1993
Object-oriented programming
Voss G., Osborne/McGraw-Hill, Berkeley, CA, 1991. Type: Book (9780078816826)
Oct 1 1992
more...

E-Mail This Printer-Friendly
Send Your Comments
Contact Us
Reproduction in whole or in part without permission is prohibited.   Copyright 1999-2024 ThinkLoud®
Terms of Use
| Privacy Policy