I just started to learn JavaScript with the book "Eloquent JavaScript", which is accessible free of charge at eloquentjavascript.net. So far I really like the book, there's just one section I don't understand. It's the one about expressions and statements:
http://eloquentjavascript.net/chapter2.html#p65af5913
I know this topic has been mentioned on StackOverflow before, however, these were more specific questions and I - quite frankly - don't get the whole thing.
In the beginning of the paragraph, the author explains what expressions are: If I understand it correctly, atomic values such as 42 or "23" are being considered expressions. If one applied those values to an operator (as in 42 - 19), this would be considered an expression, too. (I guess because it obviously turns out to be 23, which is an atomic value once again.) I interpret this the following way: Every value - no matter whether it's directly typed in or is yet to be calculated - is being called an expression. Is that correct?
Then the author says the following: "There exists a unit that is bigger than an expression. It is called a statement. [...] Most statements end with a semicolon (;). The simplest kind of statement is an expression with a semicolon after it." As an example he mentions
!false;as an example statement. My questions is "What makes this a statement? Just the semicolon at the end?" When I use the JavaScript console, it makes absolutely no difference whether I type that in with or without the semicolon. It always returns true. However, the author says that "[A] statement only amounts to something if it somehow changes the world." So the given example is not even a statement since it "just produce[s] the value [...] true, and then immediately throw[s it] into the bit bucket"? I am really confused now... If I did not entirely mess it up in my head, a statement has to have some "side-effect" (like a declaration of a variable), right?
However, I would be very happy if someone could explain what a statement is. It would also be very helpful if someone could give an example in which the distinction of those terms is actually useful, because right now I cannot even imagine why the author even bothers to introduce these vocabularies. Thank you very much in advance!