- You can call it “Java” to enrage other programmers
- You can compare numbers against strings without wasting time converting them
- it’s easy to make fun of
- it makes every other programming language look better in comparison
You’ll find an npm package to help you count up to 2.
(I recently learned - maybe here - that the is-even package has over 170k weekly downloads)
What’s even wilder is if you look at the code of that package, all it does is include the is-odd package and then return !is-odd. And the is-odd package isn’t much better, it does some basic checks on the input and then returns n % 2 === 1.
I thought I was missing something. JS is one of my main languages and I always just write the is-odd function myself since it’s like 10 characters. It boggles the mind that is-even has 176k weekly downloads
To be fair having a name can make things easier to read. I get that
i % 2 == 0
is a common pattern and most programmers will quickly recognize what is happening. ButisEven(i)
is just that much easier to grok and leaves that brainpower to work on something else.But I would never import a package for it. I would just create a local helper for something this trivial.
Exactly what I would do if I had to reuse it, especially now since I know that adding a package would actually add 2. It all just seems so…inefficient
Even if the code isn’t reused adding names to sub-expressions can be very valuable. Often times I introduce new functions or variables even if they are only used once so that I can give them a descriptive name which helps the reader more quickly understand what is happening.
- It’s not PHP.
- I don’t know. I didn’t think I’d get this far.
hmm, let’s see.
It’s not java.
It’s also not a scripting language.
also to the repeat grammar nazi in the comments here, hi, “its”
It’s not a scripting language?
- It runs in the browser
- Web developers know it already so we might as well
- It runs in browsers
- If you hate your co-workers, then they will also feel your pain.
The part that always gets me is when people choose Js for the backend. Like I get that it’s the default thing that works on the frontend, so there’s some rationale why you might not want to transpile to it from another language. On the backend though, there are so many far better option, why would you willingly go with Js, especially given that you’re now forced to do all your IO async.
It leads to typescript
You get surprises from npm
You can make minecraft mods
that’s java
1 - Easiest way to run a script in your browser
2 - Always finds its way if inputs are bad
Nan - undefinedEasiest? More like… The only way.