It's code that produces a value - that's all. Many, many things in JavaScript are expressions. Maybe it would help to see something that's not an expression? (writing on one line just for brevity) if (condition) { doThingA() } else { doThingB() } In JS, the if/else is a statement, not an expression, because it doesn't produce a value. For example, you cannot do this: let result = if (condition) { doThingA() } else { doThingB() } In some other languages (not JS), the if/else is an expression that produces a value. Same with switch, in JS it's a statement (no value) but in some other languages it's an expression (produces a value). Some other examples of expressions in JS: literals (strings, numbers, booleans, array literals, object literals, function literals, etc.) variables (like x is an expression that produces a value of whatever is in variable x) function calls Unary expressions (negation, logical not, increment/decrement, etc.) binary expressions (arithmetic, bitwise, logical, etc.) ternary expressions (conditional operator) quarternary expressions (just kidding!) Read more: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators Answer from Tubthumper8 on reddit.com
🌐
Mozilla
developer.mozilla.org › en-US › docs › Web › JavaScript › Guide › Expressions_and_operators
Expressions and operators - JavaScript | MDN
The void operator specifies an expression to be evaluated without returning a value. expression is a JavaScript expression to evaluate. The parentheses surrounding the expression are optional, but it is good style to use them to avoid precedence issues. A relational operator compares its operands ...
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-expressions-complete-reference
JavaScript Expressions Complete Reference - GeeksforGeeks
July 23, 2025 - JavaScript's expression is a valid set of literals, variables, operators, and expressions that evaluate a single value that is an expression.
🌐
Josh W. Comeau
joshwcomeau.com › javascript › statements-vs-expressions
Statements Vs. Expressions • Josh W. Comeau
If you're not a React dev, feel free to skip this section; hopefully, the rest of the tutorial will still offer a ton of value! At its core, an expression is a bit of JavaScript code that produces a value.
🌐
Reddit
reddit.com › r/learnjavascript › what exatcly is a javascript expression?
r/learnjavascript on Reddit: What exatcly is a javascript expression?
March 23, 2023 -

I used to think that it was something that returns a value,
is string a expression?
variables are expression because they are dynamic, returns a value

Top answer
1 of 3
5
It's code that produces a value - that's all. Many, many things in JavaScript are expressions. Maybe it would help to see something that's not an expression? (writing on one line just for brevity) if (condition) { doThingA() } else { doThingB() } In JS, the if/else is a statement, not an expression, because it doesn't produce a value. For example, you cannot do this: let result = if (condition) { doThingA() } else { doThingB() } In some other languages (not JS), the if/else is an expression that produces a value. Same with switch, in JS it's a statement (no value) but in some other languages it's an expression (produces a value). Some other examples of expressions in JS: literals (strings, numbers, booleans, array literals, object literals, function literals, etc.) variables (like x is an expression that produces a value of whatever is in variable x) function calls Unary expressions (negation, logical not, increment/decrement, etc.) binary expressions (arithmetic, bitwise, logical, etc.) ternary expressions (conditional operator) quarternary expressions (just kidding!) Read more: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators
2 of 3
1
I used to think that it was something that returns a value, It's a statement that returns a value. is string a expression? Yes. A bare string literal is an expression that returns the string as a value. A string assignment (e.g. const a = 'foo') is not an expression, as it does not return anything. A bare variable is also an expression that returns the value of the variable. Other things are expressions as well, like comparisons (boolean expressions),
🌐
W3Schools
w3schools.com › js › js_function_expressions.asp
JavaScript Function Expressions
Functions stored in variables do not need names. The variable name is used to call the function. ... A function expression is a JavaScript statement.
🌐
Educative
educative.io › answers › what-are-expressions-in-javascript
What are expressions in JavaScript?
Primary expressions: Consists of basic keywords and expressions. Left-hand side expressions: Left-hand side values which are the destination for the assignment operator. Primary expressions consist of basic keywords in JavaScript.
Find elsewhere
🌐
W3Schools
w3schools.com › js › js_syntax.asp
JavaScript Syntax
// Define x as a variable let x; // Assign the value 6 to x x = 6; Try it Yourself » · An identifier is the name you give to a variable. ... An expression is a combination of values, variables, and operators, which computes to a value.
🌐
Medium
tech.groww.in › expressions-in-javascript-c456dcbb1d31
Expressions in Javascript. Any unit of code that can be evaluated… | by Harshit Pruthi | The Groww Engineering Blog
April 21, 2025 - Any unit of code that can be evaluated to a value is an expression. Since expressions produce values, they can appear anywhere in a program where JavaScript expects a value such as the arguments of a function invocation.
🌐
CSS-Tricks
css-tricks.com › an-introduction-to-javascript-expressions
An Introduction to JavaScript Expressions | CSS-Tricks
October 22, 2025 - What we have here is a lesson from ... JavaScript engine interprets those input elements. An expression is code that, when evaluated, resolves to a value....
🌐
W3Schools
w3schools.com › jsref › jsref_operators.asp
JavaScript Operators Reference
Assignment operators assign values to JavaScript variables. Arithmetic operators are used to perform arithmetic between variables and/or values. Given that y = 5, the table below explains the arithmetic operators: Comparison operators are used in logical statements to determine equality or difference between variables or values.
🌐
Medium
medium.com › @khushboo_ › mastering-javascript-functions-declarations-expressions-first-class-functions-for-interviews-606b6eb3d21d
Mastering JavaScript Functions: Declarations, Expressions & First-Class Functions for Interviews. | by Khushboo | Medium
July 3, 2025 - You can give a name to a function expression too: var c = function xyz() { console.log(xyz); }; Caling c() works fine and prints the function itself, but trying to call xyz() outside won’t work because it’s only visible inside the function. JavaScript treats functions like any other value.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Functions
Functions - JavaScript | MDN
However, although the Function() constructor will create the function with name anonymous, this name is not added to the scope of the body. The body only ever has access to global variables. For example, the following would result in an error: ... A function defined by a function expression or by a function declaration inherits the current scope.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Regular_expressions
Regular expressions - JavaScript | MDN
October 30, 2025 - A regular expression (regex for short) allow developers to match strings against a pattern, extract submatch information, or simply test if the string conforms to that pattern. Regular expressions are used in many programming languages, and JavaScript's syntax is inspired by Perl.
🌐
Stanford University
web.stanford.edu › class › cs106aj › res › handouts › 08-Expressions-In-JavaScript.pdf pdf
Expressions in JavaScript Jerry Cain CS 106AJ October 1, 2018
JavaScript Console · -> 2 + 2 · 4 · -> 342 - 173 · 169 · -> 12345679 * 63 · 777777777 · -> 9 * 9 * 9 + 10 * 10 * 10 · 1729 · -> Variables · • The simplest terms that appear in expressions are constant · literals and variables. A variable is a placeholder for a value ·
🌐
DEV Community
dev.to › promisetochi › javascript-in-depth-all-you-need-to-know-about-expressions-statements-and-expression-statements-5k2
JS Expressions: All you need to know about Javascript's Expressions, Statements and Expression Statements - DEV Community
October 21, 2017 - An anonymous function can be an expression, if we use it where Javascript is expecting a value, that means we if we can tell Javascript to expect a value with parentheses, we can pass an anonymous function as that value. ... If putting a anonymous function inside a parentheses immediately returns the same anonymous function, that means we can call it straight away, like this:
🌐
W3Schools
w3schools.com › js › js_regexp.asp
JavaScript Regular Expressions
A Regular Expression is a sequence of characters that forms a search pattern. Regex is a common shorthand for a regular expression. JavaScript RegExp is an Object for handling Regular Expressions.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Statements › function
function - JavaScript | MDN
You can also define functions using the function expression. function calcRectArea(width, height) { return width * height; } console.log(calcRectArea(5, 6)); // Expected output: 30 ... function name(param0) { statements } function name(param0, param1) { statements } function name(param0, param1, /* …, */ paramN) { statements } ... The function name. ... The name of a formal parameter for the function. Maximum number of arguments varies in different engines.