An Interest In:
Web News this WeekSearch Archive
Some of Our Sources
- TutsPlus - Code
- Web Designer Wall
- The Logo Smith
- Spoon Graphics
- Six Revisions
- TutsPlus - Design
- Spyre Studios
- Android Dissected
Differences between "null" and "undefined" keywords?
They both represent a empty value.
Null means an empty or non-existent value.
Null is assigned, and explicitly means nothing. while undefined typically means a variable has been declared but not defined yet.
var a;console.log(a);// undefinedvar b = null;console.log(b);// null
var a;console.log(typeof(a));// undefinedvar b = null;console.log(typeof(b));// object
As you can see so far, null and undefined are different, but share some similarities. Thus, it makes sense that null does not strictly equal undefined.
console.log(null !== undefined);// true
But, and this may surprise you, null loosely equals undefined.
console.log(null == undefined);// true
See you soon for more tips !
Original Link: https://dev.to/nunocpnp/differences-between-null-and-undefined-keywords-2e2m