What’s the difference between var myvar; and var myvar= null;?
Try writing console.log(myVar)
and see the difference
But with var myVar
without assigning anything, myVar
is undefined
(null and undefined are different things)
2 Likes
Hello!
In the first you haven’t assigned a value, in the second the value is null;
In Javascript:
You can console.log the results
var myvar;
console.log(myvar); ----> see the result
var myvar = null;
console.log(myvar); --------> see the result
And then read the answer to this:stack overflow answer
Hope it helps!
1 Like