An expression is any valid unit of code that resolves to a value. It can be a combination of variables, literals, operators, and function calls that produce a single value.
Here are some types of expressions in JavaScript [↗]:
Arithmetic Expressions: Involving mathematical operations like addition, subtraction, multiplication, division, etc.
01: let result = 10 * (5 + 3); // Arithmetic expressionLogical Expressions: Involving logical operations using logical operators such as
&&
(AND),||
(OR),!
(NOT), etc.01: let isTrue = (true && false); // Logical expressionString Concatenation: Combining strings using the
+
operator.01: let fullName = "John" + " " + "Doe"; // String concatenation expressionFunction Calls: Invoking functions that return values.
01: let randomNumber = Math.random(); // Function call expressionAssignment Expressions: Assigning values to variables using the
=
operator.01: let x = 10; // Assignment expressionTernary Expressions (Conditional Operator): Using the conditional operator
? :
for conditional expressions.01: let age = 20; 02: let message = (age >= 18) ? "Adult": "Minor"; // Conditional expression
Here is another article you might like 😊 What Is Generator In Programming?