by echoangle · 1y ago · 0 comments
And then all of a sudden code that is expecting to get an array or undefined gets handed a zero or an empty string because someone called it with
x && [x]
Or x.length && x
And that’s how you end up with a zero showing up on a webpage instead of a list of to-do items when the list is empty.Programming languages aren't for the machine, they're for humans, and humans make mistakes so we need to design the language with that in mind. "Truthiness" is a footgun, it increases the chance you'll write something you did not mean without even realising.