In simple terms an expression is a fragment of code that produce a value. It’s doesn't matter how big or small is it. Also we have two different types of expressions, expressions with side effects and those that in some sense evaluate and therefore resolve to a value. for example:
let x = 7 // produce variable x -> with side effects
3+4 //produce 7 as a result -> resolve to a value
5 //produce 5 -> resolve to a value
- Arithmetic: evaluates to a number, much of the time use arithmetic operators like addition, subtraction, division and multiplication.
- String: evaluates to a character string, for example, “Fred” or “234”. Generally uses string operator like addition.
- Logical: evaluates to true or false. uses logical operators (&& and ||).
- Left-hand-side expressions: Left values are the destination of an assignment. for example new operator to create an instance of a class and super keyword to call functions on an object’s parent.
A program is a list of statements and every statement is separated by a semicolon. The simplest statement look like this:
Well, It isn’t too much, but when you combine statements with expressions you can create a program of any type of size.