3 ms·
Yeah I absolutely agree. The intent of that code isn’t clear - and if you need more proof, look how many different opinions there are in this thread about what
by josephg 3y ago
Yeah I absolutely agree. The intent of that code isn’t clear - and if you need more proof, look how many different opinions there are in this thread about what that code is trying to do!
Anyway, if they’re trying to coerce non-numbers into NaN, I’d write it like this:
typeof defaultValue === “number” ? defaultValue : NaN
I think that’s much more clear about the intent. I wouldn’t be confused by that code like I was confused by the code cited in the article.