2013-08

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].)

Directories for JavaScript resources

[2013-08-04] dev, javascript, jslib
I recently asked on Twitter whether people knew any good directories for JavaScript libraries and got several good answers.

2013-07

A meta style guide for JavaScript

[2013-07-30] dev, javascript, jslang
JavaScript has many great style guides. Thus, there is no need to write yet another one. Instead, this blog post describes commonly accepted meta style rules and conventions that I like that are controversial. The idea is to help you make a more informed decision about what is right for you.

ECMAScript 6 modules: the future is now

[2013-07-27] esnext, dev, javascript, jsmodules
Update 2014-09-07: Newer version of this blog post: “ECMAScript 6 modules: the final syntax”. Read it instead of this one.

This blog post first explains how modules work in ECMAScript 6, the next version of JavaScript. It then describes tools that allow you to already use them now.

In defense of JavaScript’s constructors

[2013-07-22] dev, javascript, jslang
JavaScript’s constructors have never been particularly popular: Douglas Crockford doesn’t like them and recently, more anti-constructor material has been published (two examples: blog posts by Kyle Simpson and Eric Elliott).

In this blog post, I explain that not all of the constructors’ flaws are real. But even with those that are real, I still recommend to use them. I’ll tell you why and what the future holds for constructors.

Hello Polymer: Q&A with Google’s Polymer team

[2013-07-16] dev, html5, javascript, webcomponents, google, polymer, webdev
Today, there was an online event called “Hello Polymer”, in which Polymer team members Eric Bidelman, Alex Komoroske and Matthew McNulty talked about the framework. This blog post summarizes what happened.

Trailing commas in object literals and array literals

[2013-07-14] dev, javascript, jslang
Quick reminder: trailing commas in object literals are legal in ECMAScript 5, trailing commas in arrays are ignored.

Performance optimizations and for loops

[2013-07-10] dev, javascript, jslang
This blog post looks at two common performance optimizations for for loops. Are they really faster than the canonical version?