JavaScript for PHP Developers

Title: JavaScript for PHP Developers
Author: Stoyan Stefanov
Year: 2013
For: Experienced PHP developers looking to learn about JavaScript.

This book is a wonderfully terse look at JavaScript. Sefanov (thankfully) doesn’t waste time explaining any of the fundamentals of programming and this book reads more like a diff between the two languages. There are complaints out there that the book doesn’t delve deep enough into DOM manipulation, but I feel to have done so would almost immediately make the book irrelevant. First, the book doesn’t claim that the subject is client-side JS (in fact the end of the book is catered more towards Node.js) which makes sense as it’s a book for experienced back-end developers. Secondly, most front-end JavaScript applications would be using a library or framework; to cover all of them would be a lofty goal and to cover any in great detail would make the book obsolete in a matter of months. Languages move slower than frameworks.

The Content

Stefanov cuts through the material quickly and in a typical pattern: syntax then functions then object-oriented programming. Things that are the same for both PHP and JS are mentioned in passing or skipped outright. Special attention is given to hoisting, closure, scope, and various methods for implementing inheritance. More so than any other book I’ve read on JS, the author utilizes immediate functions; reading his thoughts on immediate functions alone was worth the read.

After the introduction to the language, Stefanov goes through pretty much the whole built-in API (as of ECMAScript 3). This chapter (chapter 5) makes the book a great reference material to have lying around as it covers in-depth the global functions and built-in constructors and their methods. The oft overlooked Math, Error, and Date are given their due time here and make a great refresher for even experienced JS devs.

The savvy reader may have picked up that it’s on ECMAScript 3, not 5 or 6 (not even 4!) Chapter 6 covers ECMAScript 5 in detail including some of the less commonly used object APIs. The author also covers how to implement ECMAScript 5 while being backwards compatible. Both chapter 5 and 6 are from the perspective of the PHP developer, so each function and method are compared to their PHP equivalent when applicable.

Stefanov ends with an added bonus: a chapter of JavaScript design patterns. In this chapter closures are used to create private variables, namespace pollution is eased, constants are added (even for the ECMAScript 3 kids), and modules are covered in great detail. This is a great chapter to get a passing familiarity with CommonJS, Node.js, JSLint, and JS unit testing.

The Style

This is a short book that, with enough coffee and familiarity with general programming concepts, could be parsed in a weekend; however that is not because it’s short on material. It’s a very dense and comprehensive look at vanilla JavaScript. What it lacks in DOM coverage it makes up for its depth of coverage in complex JS concept that may seem alien to those experienced with other, more formal languages.

There are no examples to code along with and rarely any external resources to explore, as such this book can sometimes come across like reading a manual. Being familiar with JS (much more so than PHP), I didn’t find this to be a problem but I could see how complex subjects could remain murky without trying out some of the concepts in practice. In fact I liked that it didn’t have coding exercises as I could read in the park and away from my computer. Regardless, this book makes an excellent (if a little outdated) reference to have lying around.


This is a great book both for being a quick and a thorough read. Stefanov emphasizes best practices such as reducing global variables, unit testing, and linting while covering the quirks and strengths of JavaScript as well as how it differs from PHP. I would recommend it to any PHP developer as well as intermediate web developers who would like to get a deeper understanding of both JS and PHP. I’m hoping for a second edition from a ECMAScript 5 perspective while covering ECMAScript 6 (or maybe he’ll hold out until 6 has a little more widespread support). A “concise guide to mastering JavaScript” indeed!

Return Home