javascript - "var variable" returns undefined? -


when run "var variable = true;" in chrome console "undefined" returned:

> var variable = true; undefined 

but when run without "var" returns true:

> variable = true; true 

why returning "undefined" "var"?

it's confusing cause expected return true.

the first statement, while second expression. while not quite same, similar c's rules:

// statement has no value. int x = 5;  // expression... x = 10;  // ...that can passed around. printf("%d\n", x = 15); 

Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -