1

In Firefox's FireBug console, why does this happen?

>>> a = 1 1 >>> var a = 50 undefined >>> a 50 

I'm just trying to learn me some js!

1 Answer 1

4

var ... is a statement.

Statements do not have values, so the console prints undefined as the result of the statement.

Sign up to request clarification or add additional context in comments.

2 Comments

so document.write('hi'); should also return undefined (if it didn't refresh the browser)?
@DonnyP: That's different. document.write(...) is an expression, not a statement, so it has a value. However, the document.write() function returns undefined.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.