The difference between javascript statement and expression

expression:An expression is a combination of values, variables, and operators
An expression can produce a value, which may be an operation, a function call, or a literal. The expression can be placed wherever a value is required.
Arithmetic expression: 1+2
expression containing variables: x + 2
assignment expression: x=2
logical expression: 5>2
ternary expression: 5>2? True:false

Statement:
JavaScript statements are composed of the following: values, operators, expressions, keywords, and variable names. These 5 items do not have to exist at the same time.
Most JavaScript programs contain many JavaScript statements.
These statements will be executed one by one in the order in which they were written.
JavaScript programs (and JavaScript statements) are often referred to as JavaScript code.

A sentence can be understood as a behavior, and loop sentences and judgment sentences are typical sentences. A program consists of many statements, usually a semicolon; separate statements one by one.

Guess you like

Origin blog.csdn.net/weixin_43131046/article/details/114314387