Why is there Undefined & NULL both in JavaScript and What's the difference?
In JavaScript, we have NULL and Undefined which upon comparing with the equality operator returns True, because they both imply the same thing that the variable doesn't have a value. But while comparing them with the strict equality operator it returns False, because there is little difference between them and that is the NULL keyword implies that the variable or value doesn't exist but what Undefined implies is that the variable is declared but it hasn't been defined yet.
E.g. If we are searching for something in a table or JSON data file and the thing that we are searching for doesn't exist it'll return NULL but if it exists and is not defined then it'll return undefined.
And that was it. Will meet you in the next article. Thanks for reading and hope it helped you.
Subscribe to my newsletter
Read articles from Jassahib Singh directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by