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
-
RTRMS36907yYa but there is no type checking in that statement. So it does not care that the right hand side is a string.
-
@programmingTrtl I think he was - for some reason - thinking that by using the double equals operator the string would somehow magically be coerced to null or that null would be coerced to a string value.
-
@RTRMS Yes, there most definitely is type checking. The first thing that happens is both values are checked to see if they are the same type, if they are then they are evaluated against each other, if they're not the same type the abstract equality comparison algorithm is invoked.
-
@tnuhb well, an undefined variable is one which has not been defined in the current scope, a variable with the value of undefined means that the variable has been defined but has not yet been given a value, a variable with the value of null means that the variable has been defined but deliberately has no pointer to a value. Many databases/APIs return null as a value which would then get assigned to a variable.
-
philcr30547yI’m no js programmer but is that not checking a null ref against the string “null” that statement would always be true
-
Orek12987yJunior dev here. I guess it has to do something with stack and reference. Null is not assigned/ referenced to a value in stack and so second null.
Since that those are not equal. Will check it tho. -
philcr30547y@terminalterror I’m saying if you compare null to a string using != the condition would always be true because the string is not null
-
@philcr sorry, I misunderstood, and yes that's obviously going to be the case.
Related Rants
-
tahnik63So I need to create a nice new web app. Let's look at some cool JS frameworks that I can work with. *5 mins l...
-
ahmedam23What only relying on JavaScript for HTML form input validation looks like
-
mijit20*Builds a web component for a client website* CLIENT: I don't like it, can I have it a tiny bit over to the r...
Senior JS Dev where I'm contracting can't understand why null != "null"
undefined
stupidity
javascript
stupid people
javascript js
js