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.

JavaScript’s type system

[2013-09-01] dev, javascript, jslang
This blog post examines JavaScript‘s type system. It answers questions such as: Is JavaScript dynamically typed? Weakly typed? What is coercion?

2013-08

Protecting objects in JavaScript

[2013-08-25] dev, javascript, jslang
This blog post is a quick refresher of how objects can be protected in JavaScript. There are three levels of protection:
  1. Preventing extensions is the weakest level,
  2. sealing is stronger,
  3. freezing is strongest.

Why all objects are truthy in JavaScript

[2013-08-20] dev, javascript, jslang, jshistory
In JavaScript, all objects are truthy [1], even new Boolean(false), empty arrays and empty objects:
    > Boolean(new Boolean(false))
    true
    > Boolean([])
    true
    > Boolean({})
    true
That is different from how objects are converted to number and string, where you can control the result by implementing the methods valueOf() and toString() [2].

Callable entities in ECMAScript 6

[2013-08-11] esnext, dev, javascript
Update 2013-11-28: There won’t be generator arrow functions in ECMAScript 6 (details).

In ECMAScript 5, one creates all callable entities via functions. ECMAScript 6 has more constructs for doing so. This blog post describes them.

The flag /g of JavaScript’s regular expressions

[2013-08-08] dev, javascript, jslang, regexp
This blog post describes when and how to use regular expressions whose flag /g is set and what can go wrong.
(If you want to read a more general introduction to regular expressions, consult [1].)