What is the difference between null and ""?

What is the difference between “” and null in Javascript?

I have always thought that “” === null. But this question says there are 5 falsy values, i.e. false , null , 0 , "" , undefined , and NaN . Hence, I am wondering if there if there might be difference between the two

In JS, all strings are objects, even an empty one. However null is not an object (it is the absence of an object)

1 Like

Did you know that…
image

Javascript is weird


Anyway, yes, null is a special keyword, and it’s a datatype on its own. It rapresents values that are not present on purpose.

"" is an empty string, a string containing 0 characters

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.