2013-05

JavaScript quirk 5: parameter handling

[2013-05-05] dev, twelvequirks, javascript, jslang
[This post is part of a series on JavaScript quirks.]

The basics of parameter handling in JavaScript are simple, advanced tasks require manual work. This blog post first looks at the basics and then covers advanced topics.

2013-04

JavaScript quirk 4: unknown variable names create global variables

[2013-04-28] dev, twelvequirks, javascript, jslang

JavaScript quirk 3: normal equality (==)

[2013-04-24] dev, twelvequirks, javascript, jslang
[This post is part of a series on JavaScript quirks.]

Let’s start with a simple rule: the normal equality operators == and != are so problematic that you should always use strict equality (=== and !==). Some people say that there are exceptions to this rule, I disagree [2]. Keeping this rule in mind, we can now take a look at what is strange about ==, without burdening our minds unnecessarily.

Checking for undefined: === versus typeof versus falsiness

[2013-04-19] dev, javascript, jslang
There are several ways of checking whether a variable has the value undefined. This blog post explains the differences.

JavaScript quirk 2: two “non-values” – undefined and null

[2013-04-14] dev, twelvequirks, javascript, jslang
[This post is part of a series on JavaScript quirks.]

Most programming languages have only one value for “no value” or “empty reference”. For example, that value is null in Java. JavaScript has two of those special values: undefined and null. They are basically the same (something that will change with ECMAScript 6, as will be explained in the last post of this series), but they are used slightly differently.

12 JavaScript quirks

[2013-04-08] dev, twelvequirks, javascript, jslang
A core of JavaScript (the so-called “good parts”) is elegant, but that core is often obscured by quirks. This introduction is the first of a series of blog posts that looks at twelve common quirks and how to best deal with them:

JavaScript quirk 1: implicit conversion of values

[2013-04-08] dev, twelvequirks, javascript, jslang
[This post is part of a series on JavaScript quirks.]

JavaScript is very tolerant when it comes to accepting values. For example, everywhere it expects a number, it does not reject values from other types, but tries to convert them:

    > '5' - '2'
    3
    > '5' * '2'
    10
Automatic conversion to boolean is rarely problematic and often useful. It is covered here as a preparation for later – we’ll use it to work around quirks. Automatic conversion to string, however, can cause problems.

Google’s Blink: a few interesting facts

[2013-04-05] browser, dev, blink, webkit, google, webdev, chrome
With Blink, Google has created a permanent fork of the WebKit HTML engine. This blog post mentions a few interesting facts that provide context for that decision.

Enforcing toString()

[2013-04-04] dev, javascript, jslang
JavaScript usually automatically converts values to the type that a method or operator needs, which can lead to a variety of bugs. As a counter-measure, Brian McKenna (@puffnfresh) suggests using the following code for your tests:
    Object.prototype.valueOf = function () {
        throw new Error('Use an explicit toString');
    };

ECMAScript Harmony features in Node.js

[2013-04-01] esnext, dev, nodejs, javascript
Quick tip (via David Klassen): The following shell command lists all (highly experimental!) ECMAScript Harmony [1] features that can be switched on in Node.js.
    node --v8-options | grep harmony