Operators allow you to get two simple expressions and combine them to form a more complex expression.
But first.. what is an expression? An expression is a single unit of JavaScript code that the JavaScript engine can evaluate, and return a value.
An expression can be a literal, like a string or a number.
It can also be an identifier that points to a variable.
Like these:
2
'something'
true
undefined
age //where 'age' is the name of a variable
{} //an empty object
We also have other kinds of expressions.
Arithmetic expressions are expressions that take a variable and an operator (more on operators soon), and result in a number:
1 / 2
i++
i -= 2
i * 2
String expressions are expressions that result in a string:
'A ' + 'string'
Logical expressions make use of logical operators and resolve to a boolean value:
a && b
a || b
!a
More advanced expressions involve objects, functions, and arrays, and I’ll introduce them later.