Anyone please tell what is the difference between undefined and null in javascript and when I should use undefined and when null.
What is difference between undefined and null in javascript and what are their usecases? [duplicate]
2 Answers
undefined means a variable has been declared but has not yet been assigned. null is an assignment value. It can be assigned to a variable as a representation of no value
example.
var a; alert(typeof(a)); var b = null; alert(typeof(b)); Running the above script will result in the following output:
undefined object
——————————-