I have this very simple question, but I can not find any complete answer for this question.
JavaScript's null
and undefined
is the values of variables that have not been initialised and the value you get when you query the value of an object property or an array element that does not exist.
I first thought we get a referenceerror
when we attempt to access a non-existent property of an object or an array element that does not exist, but as it turns out it isn't the case.
But on which occasions actually does it throw a referenceerror
?
I appreciate if someone can tell all the situations when it can throw a referenceerror
You get a reference error when you:
JavaScript's null and undefined is the values of variables that have not been initialised
No. A variable that has been declared but not assigned a value or a property that has not been assigned a value will have undefined
as a default value. undefined
can also be explicitly assigned. null
can only be explicitly assigned.