3 ms·
Happy to! - https://jsisweird.com/ https://jsisweird.com/
by ivanmontillam 3y ago
Happy to!
- https://jsisweird.com/ https://jsisweird.com/
- rantallion 3y agoThis one gets trotted out every time someone wants to demonstrate how terrible JavaScript is. You can do many of the same stupid things in many other languages too, and most of the examples in that quiz are pretty contrived. Do you have some real-life examples of things you've personally encountered, rather than crazy examples that no-one would actually write?
- cxr 3y agoTo be clear: the context of this is a comment that "I've never found a programming language that didn't behave like I expected it on first touch, except for JS", and this quiz includes things like "0.1 + 0.2 === 0.3", which raises a few questions: Since this has nothing to do with JS per se and is a standard example to showcase the counterintuitiveness of IEEE 754 doubles, then does this mean that you have never worked with another language that uses IEEE 754 doubles? (And in what other languages do you find yourself typing "===", i.e. what would motivate you to type it out "on first touch", anyway—rather than "==", that is?) The quiz is filled with other examples like "+!![]". Can you briefly explain what intent/expected behavior is associated with the mindset a decision to type this out in a program and how JS violates those expectations and would therefore would be better if only it could be changed?
- Tade0 3y agoI meant your own examples. I've seen these many times - few people deliberately write such code.
- satvikpendem 3y agoToday I'm wrangling with null versus undefined in TypeScript and making a bunch of changes just to deal with that. I know there is a semantic difference between the two but in practice most people use them interchangeably. It's simply unnecessary to have two ways of representing nothingness when most languages simply have `null`, or even eschew it altogether by making nullability sound, via option types as in Rust, Haskell, or OCaml.