This video by ThePrimeagen sent me on a fun archaeology trip.
The case to solve: Why is the following statement true? why is an empty string parsed as a number in JS?
Number("") === 0
ECMAScript 0.14 from March 1997 and later ECMAScript 1 from June 1997 contain the following on page 26 and 28 respectively:
The MV of
StringNumericLiteral
::: (an empty character sequence) is 0.
0.14 is the first version of the spec where this appears.
But JavaScript 1.1 from November 1996 states this on page 23:
So, something happened between 1996 and 1997. But I couldn’t figure out what. There is an archive of TC39 documents from 1997, though nothing hints at the reasoning for this decision.
JScript 0.1 from 1996 seems to be the source for something similar:
Number() === 0
On page 14 it states:
The Number constructor has two modes.
- With no arguments, it returns an object whose valueOf method returns 0.
- With one argument, which must be a number, it returns an object whose valueOf method returns the argument.
Alternative names for ECMAScript were collected, some are actually pretty good but others are totally wild:
Name | Explanation |
---|---|
CoolScript | No known issues |
CoScript | No known issues. Stands for "Common Scripting System" |
Descartes | Unknown -- too many matches. |
DeScript | Unknown -- too many matches. In honor of Descartes. |
DynaScript | Used in a physics class at Moorhead State |
EScript | No known issues |
InfoScript | No known issues |
JScript | None, but it is in use by Microsoft |
JustScript | No known issues |
JSL | Acronym used -- Japanese as a Second Language. For "Just a Script Language" |
RadScript | No known issues |
ScriptJ | No known issues |
TranScript | Unknown -- too many matches. |
W3Script | No known issues |
WScript | No known issues |
wwwscript | No known issues |