2012-01

JavaScript inheritance by example

[2012-01-08] dev, javascript, jslang
Update 2012-03-19: New section on “Objects”, tips for what to read next.

This blog post illustrates several JavaScript inheritance topics via an example: We start with naive implementations of a constructor Point and its sub-constructor ColorPoint and then improve them, step by step.

Crockford’s JSDev: switching off privacy for testing

[2012-01-05] dev, javascript, jslang, jstools
Today, Douglas Crockford introduced a new project: JSDev. It solves a challenge with privacy: On one hand, you don’t want the outside world to have access to private functionality. On the other hand, you want to test it, via external unit tests.

The pitfalls of using objects as maps in JavaScript

[2012-01-03] dev, javascript, jslang
JavaScript is Spartan when it comes to built-in data structures. One commonly uses objects as maps from strings to values. This post points out three pitfalls when doing so.

The multiple roles of JavaScript objects and arrays

[2012-01-01] dev, javascript, jslang
Both objects and arrays play multiple roles in JavaScript. This blog post explains what those roles are.

2011-12

Why do some JavaScript methods have such long names?

[2011-12-28] dev, javascript, jslang
Allen Wirfs-Brock (the project editor of the ECMAScript 5 specification) recently mentioned the thought process behind method names such as Object.getOwnPropertyNames():

es6-shim – ECMAScript 6 functionality on ECMAScript 5

[2011-12-27] esnext, dev, javascript, jslang
Update 2012-03-13: Added a section on installation.

Paul Miller’s es6-shim gives you functionality that will be in ECMAScript 6 (code-named ECMAScript.next), on ECMAScript 5 engines. It was initially based on a project of mine, but adds much new functionality, Node.js compatibility, and (not least) tests.

Subclassing builtins in ECMAScript 5

[2011-12-26] esnext, dev, javascript, jslang
JavaScript’s built-in constructors are difficult to subclass. This post explains why and presents solutions.

What is the difference between a shim and a polyfill?

[2011-12-20] dev, javascript, clientjs, jslang
In the JavaScript world, one frequently encounters the words shim and polyfill. What are those things and what is the difference between them?

Duolingo: using free online language lessons to translate texts

[2011-12-19] foreign languages, education, life
Duolingo achieves an impressive win-win: Customers get to learn a foreign language for free while helping the company translate texts.

Fake operator overloading in JavaScript

[2011-12-17] dev, javascript, jslang
Update 2012-01-29: The post “What is {} + {} in JavaScript?” looks at the addition operator in more detail.

This post describes how to do a limited version of operator overloading in JavaScript. With the technique described here, you’ll be able to implement a type StringBuilder that can be used as follows:

    var sb = new StringBuilder();
    sb << add("abc") << add("def");
And a type Point that can be used as follows:
    var p = new Point();
    p._ = new Point(1, 2) + new Point(3, 4) + new Point(5, 6);
    p._ = new Point(1, 2) * new Point(3, 4) * new Point(5, 6);