The Principles of Object-Oriented JavaScript

Author: Nicholas C. Zakas
Publisher: No Starch Press
Pages: 100
ISBN: 978-1593275402
Audience: Intermediate JavaScript programmer
Rating: 4
Reviewer: Ian Elliot


Object-oriented JavaScript can mean different things to different people. In this case the approach is to treat JavaScript as a language in its own right rather trying to make it fit in with the way other languages work.

In particular, if you are looking for a book that tells you how to implement a class based inheritance hierarchy in JavaScript this is not the book you are looking for.

It is also not for the complete beginner even though it does deal with some very basic JavaScript ideas. You need to be able to program in JavaScript and you need to be prepared to change how you think about it. 


Chapter 1 explains the idea of primitive types v objects and explains how wrappers convert the primitive type to an object when necessary. A main theme is the explanation of reference v value types. In JavaScript objects are reference types and primitive types are value types. If you already know this then the main value of the chapter will come from the detailed explanation of how to tell one type from another using instanceof.

Chatper 2 introduces functions. and explains the idea of the two different ways of defining a function statements and expressions and the idea of hoisting. It then goes on to explain that functions are first class in JavaScript and you can pass them to other functions. Only then does author Nicholas Zakas point out, almost in passing, that functions are objects. For me, the idea that functions are objects is the key idea that makes it all make sense. Next, we have an explanation of parameters and the difficult-to-use this evaluation context. The explanation is clear, but based mostly on how you use this and how to use call, apply and bind, rather than any explanation of the idea behind the evaluation context. 

Chatper 3 is about objects which given their importance in JavaScript and the title of the book seems a little late. We have a fairly standard explanation of creating, testing for and removing properties. It also covers the idea of property attributes introduced in ECMAScript 5. In the main the book doesn't distinguish between different versions of JavaScript and the problem of writing code that works in all browsers. This is left as an exercise for the reader. 

Chapter 4 deals with the idea of a constructor and the prototype chain. This is a fairly standard account of the ideas and if you already understand the way constructors and prototypes work then there is nothing new here. Of course many JavaScript programmers have only a vague idea of how constructors work and an even poorer idea of how prototype works. This is mostly because they learn JavaScript as a script rather than as a full programming language and because when they try to learn more they try to understand it as if it was Java or C++ i.e. a traditional class based language. Chapter 5 pushes these ideas further with a look at inheritance hierarchies created using the prototype chain.




The final chapter - this is a short book -presents some commonly encountered patterns. The module pattern, private members, mixins and scope safe constructors. 

As just mentioned this is a very short book, only 92 pages devoted to the main text, and it is very worth reading. If you are struggling with JavaScript's advanced ideas this book will help, but it could do so much more. For example, the idea of a closure is only introduced in the final chapter almost as a throw away aspect of achieving some result. There is no real emphasis on how to think about JavaScript - in particular that nearly everything is an object, that Functions are objects, that objects are associated with values used in expressions. There is also no discussion of JavaScript's almost non-existent typing and why this is good or bad. 

In short this book is good as far as it goes and it might provide you enough information and ideas for you to see your own way to understanding how JavaScript is a logical approach to object-oriented programming without the use of classes or inheritance hierarchies. 

Recommended but with reservations. 



Machine Learning with Python for Everyone

Author: Mark Fenner
Publisher: Addison-Wesley
Pages: 592
ISBN: 978-0134845623
Print: 0134845625
Kindle: B07VRSJ1GB
Audience: AI Beginners
Rating: 3
Reviewer: Mike James
A book that claims "for everyone" is promising a lot.

SQL Server Query Tuning and Optimization (Packt)

Author: Benjamin Nevarez
Publisher: Packt Publishing Pages: 446
ISBN: 9781803242620
Print: 1803242620
Kindle: B0B42SVBFY
Audience: Intermediate to advanced DBAs and developers
Rating: 4.7
Reviewer: Ian Stirk 

This book aims to give you the tools and knowledge to get peak performance from your que [ ... ]

More Reviews



Last Updated ( Monday, 05 May 2014 )