does it not make sense to just remove it from the language completely? who is deciding that?
does it not make sense to just remove it from the language completely? who is deciding that?
if (someValue != null) {
// someValue is neither null nor undefined
}
> does it not make sense to just remove it from the language completely?No, because you'd wreck quite a bit of the internet with that.
> who is deciding that?
ECMA TC39
The way syntax is "removed from the language" in JS is by introducing commonly-used lint rules that disallow them, and that has already happened with `==`: https://eslint.org/docs/rules/eqeqeq . As long as the community makes it so a standard project setup has a linter with good defaults, `==` can effectively be removed from JavaScript without having to break nearly every website in existence (which is what would happen if browsers decided to start crashing on `==`).
The best solution currently is to have linter rules enforcing ===.
I would say that's the defining characteristics of JavaScript.
It makes it fun to write JavaScript with its quirkiness and "dynamic" nature. And once you master it you become a ninja.
Compare it to Java or Golang where you are restricted by the language syntax and anything slightly creative and fun is either not supported or not idiomatic.
nope. none of that. there are plenty of fun, dynamic languages that aren't the horrible pile of shit that is raw javascript.
> And once you master it you become a ninja.
wait, was this sarcasm? hard to tell..
1. I was making a generalized statement around JS, not specifically '=='. That's a misinterpretation of my statement.
>"my programming language is perfect"
2. I did not say JavaScript is perfect. That's a misinterpretation of my statement.
>"if you don't like it you're just too dumb to get it"
3. I did not say "if you don't like you're just too dumb." That's a misinterpretation of my statement.
JavaScript really _isn't_ all that expressive.
I just don't get it. What's wrong with expressing my love for a language that I love? I am not even asking for anyone to switch to JS, just expressing my feel.
Thanks for pointing that out.
I think might be due to the downvotes somehow. It makes you wonder if you did something wrongly or it is simply people disagreeing with you.
Sure! For starters, you can write
if (foo == null) { ... }
Because `undefined` gets coerced to `null`, it saves you from writing: if (foo === null || foo === undefined) { ... }
And, because it's shorter, it's even allowed by [some JS linters](https://standardjs.com/).There you have your JS ninja trick to handle two distinct null types^TM .
Yes, a ninja of the "undefined is not a function" wars.
In my experience, code that is "slightly creative and fun" is unreadable and not actually useful for creating working products as a part of a team.
[0]https://www.simplethread.com/dont-be-clever/