0

whenever we define a variable in console with some value for example

var f = 20;
var j = 30;

the above statement returns undefined for one time, can you please help in understanding why it returns undefined even it we have defined both the variables? Secondly if it is related to hoisting then why undefined is coming only once?

Sanchit Goel
  • 121
  • 11
  • The undefined is just the "output" of the console input. I think its only shown once for a better overview like 1 input == 1 output. – Teemoh May 14 '17 at 17:31

1 Answers1

-1

The console reports the result of evaluating the expression, equivalent to typeof basically.

typeof eval("var f = 20;");

returns undefined

bamtheboozle
  • 5,847
  • 2
  • 17
  • 31