What is the difference between adding a semicolon and not adding a semicolon in a function call? The relationship between expressions and statements, and how to distinguish expressions from statements.

for example:
the difference between fn () and fn ();.
A statement ends with a semicolon. (semicolons can be omitted)
but fn () this should be a function call expression, why sometimes add a semicolon.
is fn (); with a semicolon a statement? How to understand the
statement? What is a sentence?

Mar.10,2021

js is a weak language. In other languages, the addition of a semicolon makes a big difference. In js, a semicolon indicates the end of a statement. In fact, it only affects the next statement written on the same line, such as

.
//
fn() var a=''//Unexpected token var
//
fn();var a=''//
//
fn()
var a=''

the interpreter adds a semicolon when parsing without a semicolon. The interpreter may add the semicolon incorrectly, so it is best to add the semicolon yourself.


Don't need a semicolon, just enter. It's OK
it doesn't make much difference

well, take a look at the python tutorial when you are free.
you don't have to read too much, you can read it
and then you understand

.
Menu