Stranger Things, JavaScript Edition
livecodestream.dev
Stranger Things, JavaScript Edition
1–10 of 58 posts
Re: Stranger Things, JavaScript Edition
#2Re: Stranger Things, JavaScript Edition
#3JavaScript is the upside down.
Re: Stranger Things, JavaScript Edition
#4No, they are an embarrassment.
They don't make the language cool or interesting, they aren't tricks. They are logically incoherent nonsense.
Re: Stranger Things, JavaScript Edition
#5Re: Stranger Things, JavaScript Edition
#6More specifically, the first one was quite interesting and subtle enough that if I didn't have the `parseInt(N, 10)` rule ingrained in my head, if I had to parse a list of numbers I would try that and then scratch my head for like 30 minutes being very confused. It's also subtle enough that I could see it possibly going to production, because it could be missed if the code is only lightly tested and could be missed in a code review too.
The other one that intrigued me was the second one, and I had to look up why it works -- I didn't realize that using the + operator turns any non-parseable value into NaN.
Thanks for the cool article!
Re: Stranger Things, JavaScript Edition
#7Re: Stranger Things, JavaScript Edition
#8Either you love it or you hate it, there's no middle ground with JavaScript
Re: Stranger Things, JavaScript Edition
#9There is a relatively small list of "gotchas" in JavaScript that stem from the early days of the language. They are easily avoided. Use a linter, "use strict," use ===, and be explicit about your type conversions.
Re: Stranger Things, JavaScript Edition
#10Say what you will about the fact that these exist in the language, I found this post interesting because although realistically and thankfully I never have to deal with these quirks day-to-day, it brought me more insight to the weird nature of this language. More specifically, the first one was quite interesting and subtle enough that if I didn't have the `parseInt(N, 10)` rule ingrained in my head, if I had to parse…
Understand the difference between primitive values and object values. There are few historical bugs here with typeof that are now defined in the spec (null, undefined etc are primitive values but will give object etc).
Floating point math:
https://en.m.wikipedia.org/wiki/Floating-point_arithmetic
Type coercion:
https://exploringjs.com/deep-js/ch_type-coercion.html
Prototypical inheritance:
https://javascript.info/prototype-inheritance
How this works:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
And you will be fine for the most part. Other things you will discover on your own.
And use typescript if you can.