An Interest In:
Web News this Week
- April 24, 2024
- April 23, 2024
- April 22, 2024
- April 21, 2024
- April 20, 2024
- April 19, 2024
- April 18, 2024
June 10, 2020 06:03 pm GMT
Original Link: https://dev.to/yujiri8/two-things-i-just-learned-about-javascript-18ej
Two things I just learned about Javascript
Learned two infuriatings things today. The first is actually not that surprising: if X is unset, typeof x === 'undefined'
. I found this while running typeof nan
, and got super confused because I forgot it's spelled NaN
is JS.
The other? So I've known about the object constructors for non-object types for a while:
> n = new Number(5);[Number: 5]> typeof n'object'> console.log('wtf')
But today I got the idea to try something, and my suspicions were confirmed:
> n = new Boolean(false);[Boolean: false]> !!ntrue
Because objects are always true.
Don't you just love Javascript?
Original Link: https://dev.to/yujiri8/two-things-i-just-learned-about-javascript-18ej
Share this article:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To