0
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
9 Respostas
+ 3
Because your variable doesn't have value.
So it is showing undefined.
+ 2
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.
+ 1
Are you sure the source codes were exactly the same? you're talking about the tutorial guy Youtube channel right?
+ 1
yes Ipang javascript tutorial in freecodecamp youtube channel
+ 1
Ipang he is getting null as output
0
I don't know about other languages but in javascript
undefined is result if you define a variables but not assign its value.
Null is result if you assign null value to variable .
0
Share the link of video
0
Divya Mohan watch from 10:00 mins
https://youtu.be/PkZNo7MFNFg
0
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.