@noelle what makes this especially scary is that this is equivalent to "[]True"[2]
like, what??
@Lady Yeah, not [] being equivalent to True is weird.
@noelle i mean i get it but it is indicative of a fundamentally different understanding of []
in JS, [] is just a special kind of object, and all objects are truthy
Python doesn’t take the same “everything is an object™” approach so you wind up with more exceptional cases like that
@noelle which is why personally i don’t like Python (because i find the “everything is an object” approach to be much simpler to reason about than whatever it is Python does) but i understand how for other people, the incredibly ambiguous mess which is JavaScript would be bothersome lol
@Lady Fair enough. :)
@noelle anyway i think the reason why javascript gets a weird reputation isn’t because it lets you do weird typecasting things but because it lets you do weird typecasting things in very very few characters 😝
@Lady ...also probably fair! :)
@noelle “every operator should return a result without throwing an error” is definitely A Choice and they sure made it
@noelle (strictly speaking javascript operators can throw errors if .valueOf() or .toString() also throw errors or ultimately fail to produce primitives, but that’s not the case for any builtin thing i don’t think. maybe some of the newer ones? i’d have to check)
@Lady I figured you might respond. ;) Yeah, it's all expected behavior given the structure of the language, but the structure of the language makes me want to bop its designer with a rolled-up newspaper. :)