Various people prefer various tools, it is not the shame i guess :-)
** is newer and handy, way better 2**16 than write Math.pow(2,16)
And I would rather use Math.trunc() than Number.parseInt() - which is in play here too. In fact parseInt(inputValue, 10) with explicit radix argument is the right way to go according to Airbnb standards.
That double bit flip ~~ looks nice and short, and it could run faster than others - that is why it has it's place - but some people are really confused seeing it + this is not a bottleneck normally anyway + it "breaks" sooner than those alternatives for higher numbers...
Anyway I am seeing all of these in other people's code.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Thanks! To my shame I've never actually used either Math.trunc or ** in Javascript :D Live and learn. I'll update the post.
Various people prefer various tools, it is not the shame i guess :-)
** is newer and handy, way better 2**16 than write Math.pow(2,16)
And I would rather use Math.trunc() than Number.parseInt() - which is in play here too. In fact parseInt(inputValue, 10) with explicit radix argument is the right way to go according to Airbnb standards.
That double bit flip ~~ looks nice and short, and it could run faster than others - that is why it has it's place - but some people are really confused seeing it + this is not a bottleneck normally anyway + it "breaks" sooner than those alternatives for higher numbers...
Anyway I am seeing all of these in other people's code.