DEV Community

Mehul Lakhanpal
Mehul Lakhanpal

Posted on

Hard truth about `null`

Alt Text

Top comments (9)

Collapse
 
adam_cyclones profile image
Adam Crockett 🌀

Hey I'm sorry I can't read ligitures what are you trying to say?

Collapse
 
ml318097 profile image
Mehul Lakhanpal

null is mad. It's not equal to zero but it's greater than or equal to zero

Collapse
 
adam_cyclones profile image
Adam Crockett 🌀

Haha I see, is that because it's prototype is object?

Thread Thread
 
ml318097 profile image
Mehul Lakhanpal

typeof null is object, but null does'nt have object as prototype. I guess its happening because of the rules of casting

Thread Thread
 
adam_cyclones profile image
Adam Crockett 🌀 • Edited

You could always make your own null and fix it with valueOf.

class Null {
    valueOf() {

     }
}
Collapse
 
lagsurfer profile image
Barney

I think the post's body is missing. But if your variable is a null and gets to a part where you compare it to something it's bad code :D

Collapse
 
ml318097 profile image
Mehul Lakhanpal

There is no body. Just printed out null problems XD

Collapse
 
omrfrks profile image
omrfrks

js has a lot of awkward points. looks like you catch one of them.

Collapse
 
ml318097 profile image
Mehul Lakhanpal

Lol. I didn't find on my own. I read it somewhere