var is a statement. Statements have no value, so eval() (which the console calls) returns undefined.
a = 123 is a simple expression, which returns 123 (so that you can write b = a = 123). When passed an expression, eval() returns the expression's value.