That wasn't the point of this exercise - nobody is saying that these are actual code examples you'd see in real life.
The point is that in lots of languages these statements would simply result in compile time errors. In JS, though, the type coercion rules are so loose (and in many cases extremely non-obvious) that you can see this head-scratching behavior.
It's the same underlying behavior that leads to very cool/very insane stuff like JSFuck: https://jsfuck.com/
The point is that in lots of languages these statements would simply result in compile time errors. In JS, though, the type coercion rules are so loose (and in many cases extremely non-obvious) that you can see this head-scratching behavior.
It's the same underlying behavior that leads to very cool/very insane stuff like JSFuck: https://jsfuck.com/