Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
June 10, 2020 06:03 pm GMT

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:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To