I visited my parents at their house. In it was an old computer of mine I used during my times at SISCOG, Runtime Revolution and Onfido. Checking my CV, it probably used it between 2011 and 2022. The computer still works, obviously. Browsing the web, however, is a much different experience. Large sites load slow. On some, the design doesn’t loads completely and they look funny. I should have taken a screenshot.

It was in that computer I began blogging more frequent and in it I found a draft post about JavaScript. Not knowing my original intentions I think I wanted to write a summary of Douglas Crockford’s talk The Better Parts at NDC 2014. The file’s last modified date is February 2018. That’s when I started at Runtime Revolution and when I started working with JavaScript. So I was likely learning and blogging about it.

So it goes.


The Better Parts

Watched Crockford’s presentation at NDC 2014 https://vimeo.com/97419177

The first 10 minutes

From 10 to 20

Pay the semi-colon

Don’t trust the automatic semi-collon insertion. This can lead to silent errors you’ll see elsewhere thus harder to trackdown.

End your statements with ;.

Tail calls

For some reason tail call recursion didn’t work well but now they do.

Splat operator ...

function curry(func, ...first) {
  return function (...second) {
    return func(...first, ...second);
  };
}

This doesn’t offer any new functionality but lets you writte cleaner code.

Module

Let

let is the new var and introduces block scope. Just like Lisp’s let.

Destructuring

This lets you perform multiple property assignment on a variable

// the old way
let that = some_object.that, other = some_object.other;

// the better way
let {that, other} = some_object;

This kind of reminds me of Lisp’s multiple-value-bind:

λ: (multiple-value-bind (f r)
       (floor 130 11)
     (list f r))
=> (11, 9)

WeakMap

From 20 to 30

Crockford reviewed some of the stuff he changed his mind about after wroting The Good Parts:

  1. No more new;
  2. No more Object.create;
  3. No more this.;
  4. No more for loops. Use .forEach instead:
  5. No more for in. Use Object.keys(object).forEach instead;
  6. No more while. Tail call recursion is the new norm;
  7. No more null. Use undefined instead.

From 35 to

Closure

Block scope and function scopes are now available.


It ends abruptly. I wonder what happened to never finish it.

The original video is not available on Vimeo anymore but one can find other presentations in the web.

There’s one feature which I compare it with Lisp. I remember, when I started at Runtime, keeping notes on Lisp patterns and how to apply them in JavaScript. So maybe is was taking notes for myself or for another From Lisp to X presentation.

🤔