I am new in Javascript and play around with some stuff. In Chrome console I written this code.
var a;
console.log(a)
Output:undefined undefined
Can anybody pls explane me why I am getting twice?.
I am new in Javascript and play around with some stuff. In Chrome console I written this code.
var a;
console.log(a)
Output:undefined undefined
Can anybody pls explane me why I am getting twice?.
console.log()
outputs a value to the console because you called it and that is what console.log()
does.
The return value of the last statement is then output to the console because you are running code on the console.
It is coincidence that those values are both undefined
.
If you set var a = 1
then you would get 1
(what you logged) and then undefined
(return value) instead.