2011-11

Myth: JavaScript needs classes

[2011-11-04] esnext, dev, javascript
Updates:
  • [2012-03-17] I completely rewrote this post and changed its name (which previously was “JavaScript does not need classes”).
  • [2012-07-29] Classes have been accepted for ECMAScript.next.
  • [2012-10-03] Since this article has been written, it was decided that ECMAScript will have the special property __proto__ instead of the <| operator.
  • [2013-10-21] Instead of the extension operator, ECMAScript.next will have the function Object.assign().
A popular JavaScript myth is that JavaScript’s prototypal inheritance is complicated and that to fix it, we need classes. This post explains that that opinion is not completely wrong, but misses some important points.

Uncurrying “this” in JavaScript

[2011-11-02] dev, javascript, advancedjs, jslang
Update 2011-12-17: New section “Making uncurryThis() safe to use in the presence of untrusted code”.

This post explains applications of uncurrying and currying this in JavaScript. It has been triggered by a tweet of Brendan Eich’s.

2011-10

A quick overview of JavaScript

[2011-10-30] dev, javascript, jslang
Update 2013-06-22:Basic JavaScript: an introduction to the language” is an improved longer version of this post.

This post gives an overview of JavaScript that is as short as possible, but explains every major feature. Give the language a chance! You have to learn its quirks, but then it is fun to program in.

Real-world Twitter

[2011-10-29] mobile, app, iphone, computers
“Big Words” is a very simple iPhone app idea: Use your mobile device to display Twitter-style messages to other people, in the real world. Fittingly, one of its creators is a Twitter co-founder.

JavaScript: Why the hatred for strict mode?

[2011-10-28] dev, javascript, jslang
There seem to be people who hate ECMAScript 5’s strict mode. This post shows that this hatred is not justified and provides work-arounds for features that are missing.

String concatenation in JavaScript

[2011-10-25] dev, javascript, jslang
There are two ways of doing string concatenation in JavaScript. This post demonstrates them and explains which one is faster.

Enums for JavaScript

[2011-10-24] dev, javascript, advancedjs, jslang
This post describes a JavaScript implementation of enums, enumerations of symbols. The idea originally comes from Allen Wirfs-Brock, via a thread on the es-discuss mailing list.

Printing objects on Node.js

[2011-10-23] dev, nodejs, javascript
Problem: If a data structure is too deeply nested, Node.js stops showing the details. This post presents two solutions.

Universal modules (browser, Node.js): imports and universal tests

[2011-10-20] dev, javascript, jsmodules, jslang
Update 2011-11-19. This post is now superseded by “Bridging the module gap between Node.js and browsers”.

This post explains how to write modules that are universal – they run on browsers and Node.js. A previous post showed a simple way of doing so, this post presents a more sophisticated solution that also handles modules importing other modules. Additionally, we use the unit test framework Jasmine to write tests for those modules that are equally universal.

Universal unit testing (browser, Node.js) with Jasmine

[2011-10-18] dev, javascript, jsmodules, jslang, jstools
Update 2011-11-19: Bridging the module gap between Node.js and browsers. [With the given information, you can write your unit tests as modules that run on both platforms.]

This post gives a quick introduction to the JavaScript unit test framework Jasmine. It has the advantage of allowing tests to be run both in browsers and on Node.js.