Commentary on Javascript: The Good Parts

"The Good Parts" has been a good read. The language has been described briefly and consistently from ground up, including a thorough explanation of objects, functions, closures and arrays. A great addition to the mix is a description of the numerous pitfalls and design problems. It seems opinionated at some points (more on this later), but very valuable as a whole. (That's correct - "The Good Parts" actually has two appendices dedicated to the not-really-good ones.)

My commentary for selected parts of the book follows.

Read more…

Interfaces dissected

Recall methods. A method is some piece of code that can be "called on objects". There are two things to methods: They're meaningful with an object to call on, and their interface looks like "they can be called with some arguments to return a value".

Properties are similar to methods, in that a property is meaningful when paired with an object. They have a different interface than methods, though: you don't "call" them; instead you "get" and "set" their "current value".

We normally consider properties and methods to be some abstract "traits" of objects. But why not treat them as first-class objects too? Imagine properties and methods as building blocks for object interfaces. A method would be an object that describes callable parts of other objects, while a property describes readable and assignable parts.

Read more…