Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
coolq48267y@harrizsb
Types and values are not checked the same way in JavaScript as they are in other languages.
In JS, you must use the "===" operator to check value _and_ type.
Technically, at least from the programmers perspective, "10" and 10 hold the same _value_ but they are different types(string and int).
The "==" operator checks only the type.
So yes, this is true:
"10.0" == 10
But this is not:
"10.0" === 10
Keep in mind that this is also true:
10.0 === 10
This "quirk" can be quite useful at times. But you must know that it exists.
There are many subtleties in JS.
This is one of them 😉 -
harrizsb7317y@coolq yup i did know that but i was inspired by how strict javascript is, which make my eyes keep open for this kind of thing
Related Rants
-
dfox14I’ve been inspired by programming many times, but a few early moments really stand out for me. Some of those...
-
donuts21Clearly right now... Just spent 2 days writing a minesweeper clone because I wanted the ability to undo. It's...
-
lucniner15Finally finished both books and got some inspiration on how i wanna code in the future
When a == b is true after initialize these
var a = 10, b = "10.0";
rant
wk79