Elf M. Sternberg

Full Stack Web Developer

Where one teaches, two learn.

Tag: #functional programming

To all tags

Programmable Semicolons

What does this Javascript do?

let x = "Hello";
let x = x + ", World!";

It prints "Hello, World!", right? So how about this?

new Promise((resolve, reject) => resolve("Hello"))
    .then((a) => (a + ", World))
    .then((a) => console.log(a));

It does the same thing, right?

Okay, so let me ask you an important question: in the second code sample, where are the semicolons?

That's one of the most interesting questions in functional programming. Let me explain why: