What is the difference between null and undefined in JavaScript?
Share
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Null and Undefined are both data types in JavaScript. Undefined is a variable that has been declared but not assigned a value. Null as an assignment value. … However, when you assign null to a variable, you are declaring that this value is explicitly empty.
Example:
The value ‘undefined’ denotes that a variable has been declared, but hasn’t been assigned any value. On the other hand, Javascript null refers to a non-existent object, which basically means ’empty’ or ‘nothing’. They’re both values usually used to indicate the absence of something . Also, undefined and null are two distinct types: undefined is a type itself (undefined) while null is an object .
Nice Tutorial. Thanks