have you ever *really* stopped to think about how wild it is that [].join("\n") returns "" — what is it joining??
8 replies
@zachleat I'm actually a big fan of this: it has a negative `wat` factor. It has to return a string, and it does; and there's nothing at all to join, so there's nothing at all in the string: it's just empty. If only the rest of the language were as predictable & consistent 😛
@zachleat https://262.ecma-international.org/#sec-array.prototype.join
Because R gets set to '' before it starts a loopin over values and gets returned at the end regardless. :D
-
@clhenrick @zachleat I feel like I just fixed a bug at work the other day related to this. It evaluates to true, doesn't it?
@bw @zachleat Wait until you go down the rabbit hole of Church Numerals, Lambda Calculus and other related calculi.
This is a pretty good initial eye-opener:
https://www.youtube.com/watch?v=RcVA8Nj6HEo
There's also some videos of folks who will take an extremely basic programming "environment" where code and data are the same, and bootstrap a language out of it.