2011-09

JSHint – a JavaScript code quality checker

[2011-09-04] dev, javascript, jslang, jstools
JSHint is a tool that analyzes JavaScript source code to warn about quality problems. This post describes how to use it.

Currying versus partial application (with JavaScript code)

[2011-09-01] dev, javascript, advancedjs, jslang
Currying and partial application are two ways of transforming a function into another function with a generally smaller arity. While they are often confused with each other, they work differently. This post explains the details.

2011-08

How to write and unit-test universal JavaScript modules (browser, Node.js)

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

Node.js has a very nice module system that is easy to understand, yet distinguishes between the exports of a module and things that should be private to it. This post explains how the code of a Node.js module can be modified so that it works on both Node.js and web browsers. It also explains how to unit-test such code.

Spreading arrays into arguments in JavaScript

[2011-08-24] dev, javascript, jslang
Update 2012-02-01: Complete rewrite of the section on spreading constructor arguments.

Sometimes, one needs to spread the elements of an array, to use them as the arguments of a function call. JavaScript allows you to do that via Function.prototype.apply, but that does not work for constructor invocations. This post explains spreading and how to make it work in the presence of the new operator.

An introduction to JSDoc

[2011-08-17] dev, javascript, jslang, jstools

Check out my book (free online): “Speaking JavaScript”. Updated version of this blog post: chapter “JSDoc: Generating API Documentation”.

Update 2011-08-19. Tweet from JSDoc’s creator, Michael Mathews:
Awesome article about JSDoc. I learned (er remembered) a few things from reading it myself! via @rauschma 2ality.com/2011/08/jsdoc-intro.html

JSDoc is the de facto standard for documenting JavaScript code. You need to know at least its syntax (which is also used by many other tools) if you publish code. Alas, documentation is still scarce, but this post can help – it shows you how to run JSDoc and how its syntax works. (The JSDoc wiki [2] is the main source of this post, some examples are borrowed from it.)

What is the correct media type for JavaScript source code?

[2011-08-15] dev, javascript, clientjs
Question: What media type should you use for JavaScript source code? Answer [via Brendan Eich] and explanations after the break.

JavaScript’s JSON API

[2011-08-06] dev, javascript, jslang
JSON is a plain text data storage format. This blog post describes what it is and how to work with it via an ECMAScript 5 API.

JavaScript performance: Array.prototype versus []

[2011-08-01] dev, javascript, jslang
Array.prototype contains many generic methods that can be applied to array-like objects. [] is a popular shortcut for accessing these methods. This post examines the pros and cons of using that shortcut.

Update: Inspired by a comment from Kevin Roberts, I’ve added a third way of accessing generic methods, and a conclusion.

2011-07

test262 – ensuring that JavaScript implementations comply with the ECMAScript specification

[2011-07-28] dev, javascript, jslang
With so many JavaScript implementations out there, how do you guarantee that all of them stay true to ECMA-262 (the ECMAScript language standard)? The answer is test262, a suite of tests to be run by an implementation. Quote from the test262 website:

ECMAScript.next: Array.from() and Array.of()

[2011-07-26] esnext, dev, javascript, jslang
Update 2014-05-08. Newer version of this post: “ECMAScript 6’s new array methods

On July 9th, Brendan Eich announced that Rick Waldron had prototyped [1] two new methods for ECMAScript.next: Array.from() and Array.of(). Both methods are also useful in current JavaScript.