And you might get a question like this, what will do logged in the first example and in the second
example.
To answer correctly, you must understand the difference between null and undefined inside JavaScript,
as you can see here, we have two examples.
In first example, we didn't assign anything to our variable, which means this variable is not defined
yet.
This is why we went here with console.log this variable.
It will be equal undefined and here after this were console.log and the type of this variable and the
name of the type will also be undefined.
And here we have our second example where inside our variable tool were signed null value and here were
console.log Envato.
And as you can understand, here we have our value now.
This is what we will see on the screen.
But type of variable too will be an object because there is no such type as now.
This is why the type of variable is an object.
Let's check this out and alert the page and we get in here and define it.
This is our variable one here saw the value of it is undefined.
The type of undefined is undefined as screen.
Now, after this work, console.log invert to here where I get now.
This is our value and type of variable to is an object.
So you really must distinguish in JavaScript between now and undefined undefined.
It means that the variable is declared, but the value is not assigned yet inside this variable.
This is exactly what we have here on Line three and null in JavaScript is an assignment value, which
means it's a value that we can assign inside the variable in our case here, where sign in null inside
variable tomb.
And even if you answered correctly here into the human might ask you.
But what is really the difference between now and undefined?
Well, we need to use null and when we need to use and define it.
And actually, it is a tricky one because normally in normal languages, we have only a single property,
which means that the variable does not exist, for example, Neal.
But in JavaScript, we have two different things.
We have undefined and we have now.
And actually, it really depends on your coattail and your team because you can use both of them inside
project.
But for example, I prefer to always use on Nahles and try to have as little undefined INTs as possible.
But obviously, if you are trying to find a value inside the ray, you will get that undefined and not
null because we didn't find anything.
So the answer here that it is fine to use both of them and that is not really something better in one
or another.