A JavaScript Constructor Problem

Constructors that fail when called without new are a potential problem, and three solutions we can use are, respectively, auto-instantiation, overloading the constructor, or killing such calls with fire. Here's the rest of the article.…

begin in ES6

In order to write a begin lookalike in ES6, we can take advantage of the fact that in JavaScript arguments are evaluated from left to right. This leads to: const begin = (...args) => args[args.length - 1]; We can therefore replicate SICP's make-withdraw procedure as: const makeWithdraw = bal =>…

let in ES6

A possible way of expressing Scheme let expressions, such as (let ((x 3) (y 5)) (+ x y)) is to use ES6 default parameters: ((x = 3, y = 5) => x + y)() It is possible to go one step further by defining an auxiliary let_ function as: const let_ = f => f(…

Unit tests

"Unit tests prove that a solution works in a particular way, rather than asserting that it solves a particular problem." (J. Humble et al.)…