I was just starting to learn JavaScript using the Eloquent JavaScript book, available for free at eloquentjavascript.net. While I really like the book, there is only one section that I don’t understand. This is one of the expressions and statements:
http://eloquentjavascript.net/chapter2.html#p65af5913
I know that this topic has already been mentioned in StackOverflow before, but these were more specific questions, and I - frankly - do not understand everything.
At the beginning of the paragraph, the author explains which expressions: if I understand correctly, atomic values, such as 42 or "23", are considered expressions. If you apply these values to an operator (as in 42-19), this will also be considered an expression. (I think because it obviously turns out to be 23, which is an atomic value again.) I interpret it as follows: Each value, regardless of whether it was directly entered or not yet calculated, is called an expression. It is right?
The author then says the following: “There is a unit that is larger than the expression. It is called an operator. [...] Most statements end with a semicolon (;). The simplest type of statement is an expression with a semicolon after it.” As an example, he mentions
! false;
as an example. My questions are:
"What does this statement do? Just a semicolon at the end?" When I use the JavaScript console, it doesn't really matter if I find it with or without a semicolon. It always returns true. However, the author says that "expression [A] only comes down to something if it somehow changes the world."
So this example is not even an operator, because it "just produces [s] the value [...] true and then immediately throws [s it] into the bucket bit"? I'm really confused now ... If I hadn't completely messed it up in my head, the statement should have some “side effect” (like declaring a variable), right?
However, I would be very happy if someone could explain what the statement is. It would also be very useful if someone could give an example in which the difference between these terms is really useful, because now I can’t even imagine why the author even bothered to introduce these dictionaries. Thank you so much in advance!