Undefined != null
In JavaScript, undefined means a variable has been declared but has not yet been assigned a value, and null is an assignment value. It can be assigned to a variable as a representation of no value.
Example:
javascript
// undefined let TestVar; console.log(TestVar); // shows undefined console.log( typeof TestVar); // shows undefined // null let TestVar = null ; console.log(TestVar); // shows null console.log( typeof TestVar); // shows object // it is clear that undefined and null are //two distinct types: // undefined is a type itself (undefined) //while null is an object. null === undefined // false null == undefined // true null === null // true |
JavaScript Common Mistakes
JavaScript is an easy language to get started with, but achieving mastery takes a lot of effort, time, and patience. Beginners often make a few well-known mistakes.
In this article, we’ll cover some of the most common learning mistakes people make and find out how to overcome them. Many of these tips will be applicable outside of JavaScript or even web development.
Contact Us