2012-06

ECMAScript.next: for-of, iterators, generators

[2012-06-11] esnext, dev, javascript
[2015-02-26] New version of this blog post: “Iterables and iterators in ECMAScript 6

ECMAScript.next’s for-of loop will provide a new and quirk-free way of iterating over all kinds of data. This blog post explains how it works and how you can try out a prototype implementation in Firefox 13 and later.

A closer look at Underscore templates

[2012-06-07] underscorejs, dev, javascript, jslang
Underscore.js is a highly useful complement to JavaScript’s rather sparse standard library. In a pinch, Underscore gives you simple templating, too. This post explains how it works and gives tips.

Notes from the Fluent JavaScript conference

[2012-06-05] fluentconf, dev, javascript
Technical publisher O’Reilly organized their first JavaScript conference, called “Fluent”, May 29-31 in San Francisco. This blog post collects random impressions of mine from that conference. They should be interesting even if you haven’t attended Fluent (hint: links to videos).

2012-04

Declaring module exports (Node.js, AMD)

[2012-04-24] dev, nodejs, javascript, jsmodules, clientjs, jslang
Modules are mostly the same in Node.js and AMD [1]: A sequence of statements that assign internal values to variables and exported values to an object. This blog post shows several patterns for doing the latter. It also explains how ECMAScript.next handles exports.

How numbers are encoded in JavaScript

[2012-04-19] numbers, dev, javascript, jsint, jslang
All numbers in JavaScript are floating point. This blog post explains how those floating point numbers are represented internally in 64 bit binary. Special consideration will be given to integers, so that, after reading this post, you will understand what happens in the following interaction:
    > 9007199254740992 + 1
    9007199254740992

    > 9007199254740992 + 2
    9007199254740994

Node.js: expanding shortened URLs

[2012-04-17] dev, nodejs
This blog post explains how one can use Node.js to expand a URL that has been shortened by a service such as t.co (built into Twitter) and bit.ly. We’ll look at a simple implementation and at an advanced implementation that uses promises.

Offer files for download in HTML5: a[download]

[2012-04-16] dev, html5, webdev
The new attribute download for <a> tags allows one to offer a file for download – instead of displaying it in the browser.

ECMAScript 6: arrow functions and method definitions

[2012-04-12] esnext, dev, javascript
Follow-up blog post from 2013-08-11:Callable entities in ECMAScript 6”.

In JavaScript, one aspect of creating a function inside a method is difficult to get right: handling the special variable this. ECMAScript.next will make things easy by introducing two constructs: arrow functions and method definitions. This blog posts explains what they are and how they help.

Handing variables to eval

[2012-04-04] eval, dev, javascript, jslang
Problem: You have an object that assigns values to names and want to use those names in an expression that is to be evaluated by eval. The classic solution is to use the with statement. But that statement is deprecated [1], starting with ECMAScript 5 strict mode [2]. This blog post describes an alternative implementation technique.

2012-03

Converting a value to string in JavaScript

[2012-03-29] dev, javascript, jslang
In JavaScript, there are three main ways in which any value can be converted to a string. This blog post explains each way, along with its advantages and disadvantages.