undefined or null
the var a in this program is not defined. so it is printing undefined. but the tutorial guy is getting null value as result but i am getting undefined. can anyone tell me why? https://code.sololearn.com/WFVPAcuaTrQK/?ref=app
Because your variable doesn't have value. So it is showing undefined.
Vanilla JS always assigns unassigned variables (without an initial value) to undefined, undefined being an primitive data type. Null is the *intentional* absence of an object. I am really confused, I don't know why he is getting null. Maybe modified JS, interpreter settings (if there are any), I really don't know. I couldn't either found anything on the internet.
Are you sure the source codes were exactly the same? you're talking about the tutorial guy Youtube channel right?
Ipang he is getting null as output
Share the link of video
That's a case among UB (Undefined Behavior) ones. When a value is set without, initialization or without assigning it, so using this last one will be an ill-formed situation.
Error in Program