2013-11

Immediately invoked constructors and object literals

[2013-11-08] dev, javascript, jslang
By now, you are probably familiar with immediately invoked function expressions (IIFEs, [1]). This blog post looks at immediately invoked constructors and immediately invoked object literals.

2013-10

The history of “typeof null”

[2013-10-29] dev, javascript, jslang, jshistory
Update 2013-11-05: I take a look at the C code of typeof to better explain why typeof null results in 'object'.

In JavaScript, typeof null is 'object', which incorrectly suggests that null is an object (it isn’t, it’s a primitive value, consult my blog post on categorizing values for details). This is a bug and one that unfortunately can’t be fixed, because it would break existing code. Let’s explore the history of this bug.

The dict pattern: objects without prototypes are better maps

[2013-10-14] dev, javascript, jslang
Using objects as maps from strings to values has several pitfalls. This blog post describes a pattern that eliminates some of them.

The JavaScript console API

[2013-10-05] dev, nodejs, javascript, clientjs
In most JavaScript engines, there is a global object console with methods for logging and debugging. That object is not part of the language proper, but has become a de facto standard, since being pioneered by the Firebug debugger. Since their main purpose is debugging, the console methods will most frequently be used during development and rarely in deployed code.

This blog post gives an overview of the methods of console.

Safe integers in JavaScript

[2013-10-01] numbers, dev, javascript, jsint, jslang
Update 2014-02-08: Follow-up blog post “What are integers in JavaScript?

JavaScript can only safely represent integers i in the range −253 < i < 253. This blog post examines why that is and what “safely represent” means. It is based on an email by Mark S. Miller to the es-discuss mailing list.

2013-09

Tips for using window in JavaScript

[2013-09-29] dev, javascript, jslang
In web browsers, window refers to an object that contains the global variables. This blog post explains how it works and when to use it.

Unicode and JavaScript

[2013-09-24] dev, javascript, unicode, jslang
Update 2013-09-29: New sections 4.1 (“Matching any code unit”) and 4.2 (“Libraries”).

This blog post is a brief introduction to Unicode and how it is handled in JavaScript.

The ECMAScript Internationalization API

[2013-09-22] dev, javascript, jslang
The ECMAScript Internationalization API is a standard JavaScript API that helps with tasks related to internationalization: collation, number formatting, date and time formatting. This blog post gives a brief overview and points to more reading material.

OS X: kill all Google Chrome tabs from the shell

[2013-09-16] browser, chrome, mac
If there are a lot of tabs open in Google Chrome, it tends to become slow. Killing tabs by hand, via the Task Manager helps, but is tedious. The following bash script (by Sindre Sorhus) lets you conveniently kill all open tabs from the shell (OS X only):

Data in prototype properties

[2013-09-10] dev, javascript, jslang
Update 2013-09-14: New sections 1.2, 2 and 3.

This blog post explains when you should and should not put data in prototype properties.