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.
Discussions

What exatcly is a javascript expression?
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 More on reddit.com
🌐 r/learnjavascript
26
3
March 23, 2023
What are the point of function expressions? When should I use them?
The important thing about them is you can pass functions to other functions. That allows for really powerful stuff. A lot of built-in functions make use of this: map, filter, sort, etc. Coming from a language that doesn't have first class functions, they blew my mind. But I can see how if you learned a language with first class functions as your first language, perhaps they wouldn't seem so extraordinary! Because after all, they are just like any other data type: you can assign them to a variable, you can put them in a dictionary ("object" in javascript terms), you can pass them to functions, etc. etc. Nothing seems unique about functions from that perspective. But take my word for it: there are languages that don't treat functions this way, and those languages are painful to work with once you are used to first class functions. More on reddit.com
🌐 r/learnjavascript
12
8
October 19, 2023
JavaScript: declarations vs expressions vs statements - Stack Overflow
However, none of the articles and SO questions I read provided me with a cheatsheet of sorts to distinguish between the 3 (or the 2, expressions vs statements). Something I have noticed with statements is that they all somehow involve a special JavaScript keyword like break or for or var. More on stackoverflow.com
🌐 stackoverflow.com
Jexl: Javascript Expression Language. It's everything you wish you could safely eval(), and then some.
I've never wanted to eval anything. Why would I need this? More on reddit.com
🌐 r/javascript
29
79
March 11, 2015
🌐
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.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Operators › function
function expression - JavaScript | MDN
The main difference between a function expression and a function declaration is the function name, which can be omitted in function expressions to create anonymous functions. A function expression can be used as an IIFE (Immediately Invoked Function Expression) which runs as soon as it is defined.
🌐
Josh W. Comeau
joshwcomeau.com › javascript › statements-vs-expressions
Statements Vs. Expressions • Josh W. Comeau
Expressions can contain expressions. For example, how many expressions do you count in this chunk of JS code? Make a guess, and then drag the slider to see them each highlighted: ... A JavaScript program is a sequence of statements.
🌐
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

Find elsewhere
🌐
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.
🌐
Masaryk University
fi.muni.cz › ~xdohnal › manuals › jscript › expr.html
JavaScript Values, Expressions, and Operators
Zero bits are shifted in from the left. For example, 19>>>2 yields 4, because 10011 shifted two bits to the right becomes 100, which is 4. For postive numbers, zero-fill right shift and sign-propagating right shift yield the same result. Logical operators take logical (Boolean) values as operands. They return a logical value. Logical values are true and false. ... The logical "and" operator returns true if both logical expressions expr1 and expr2 are true.
🌐
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.
🌐
Mozilla
developer.mozilla.org › en-US › docs › Web › JavaScript › Guide › Regular_expressions
Regular expressions - JavaScript | MDN
A regular expression pattern is composed of simple characters, such as /abc/, or a combination of simple and special characters, such as /ab*c/ or /Chapter (\d+)\.\d*/. The last example includes parentheses, which are used as a memory device.
🌐
JavaScript.info
javascript.info › tutorial › the javascript language › javascript fundamentals
Function expressions
January 22, 2025 - In JavaScript, a function is not a “magical language structure”, but a special kind of value. The syntax that we used before is called a Function Declaration: ... There is another syntax for creating a function that is called a Function Expression.
🌐
Reddit
reddit.com › r/learnjavascript › what are the point of function expressions? when should i use them?
r/learnjavascript on Reddit: What are the point of function expressions? When should I use them?
October 19, 2023 -

Learning JavaScript and came across function expressions. The thing is, they just seem like standard functions. I don’t really even see how they’re “anonymous” since they have a variable name instead of a function name. The only different I can see is that function declarations are hoisted, whereas function expressions are not.

So then what’s even the point of them then? Are they just for making a function that is used only for a small scope of code? Or am I just missing something obvious about them?

🌐
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.
🌐
Medium
medium.com › launch-school › javascript-expressions-and-statements-4d32ac9c0e74
JavaScript Expressions and Statements | by Madhu M | Launch School | Medium
December 25, 2018 - 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....
🌐
TutorialsPoint
tutorialspoint.com › home › javascript › javascript function expressions
JavaScript Function Expressions
September 1, 2008 - The function expression allows us to define a JavaScript function in an expression. JavaScript functions are defined using a function declaration or a function expression. The main difference between them is the function name.
🌐
The Valley of Code
thevalleyofcode.com › javascript-expressions
JavaScript Expressions
JavaScript Expressions · Expressions are units of code that can be evaluated and resolve to a value. Expressions in JS can be divided in categories. Arithmetic expressions · String expressions · Primary expressions · Array and object ...
Top answer
1 of 3
19

There are standard definitions of these terms that all languages, including JS, follow. My takes on them are the following:

  • An expression produces a value and can be written wherever a value is expected.

  • A statement on the other hand is is a standalone unit of execution. It does not return anything.

  • A declaration is a statement in which a value is assigned to a variable.

  • All declarations are statements, but not all statements are declarations.

  • Most statements and all declarations contain expressions.

Javadoc also gives nice, succinct definitions:

An expression is a construct made up of variables, operators, and method invocations, which are constructed according to the syntax of the language, that evaluates to a single value.

Statements are roughly equivalent to sentences in natural languages. A statement forms a complete unit of execution.

Now, your theory on keywords being necessarily involved is incorrect. Here is a statement that includes a keyword:

break;

And here is one that does not:

foo();

In the first example I execute a break, whereas in the second one I call a function. Both are statements, however only one includes any special keyword.

A function is not a statement. A function call is a statement, as demonstrated above. In the case of a function that returns something, the call can also be a declaration:

var bar = foo();

And for your final question, the reason there is so little material out there on this is because this is merely an issue of semantics. People do not linger on the exact definitions of these terms.

For further clarification, I recommend taking a look at this blog post by Axel Rauschmayer that specifically talks about the difference between statements and expressions in JS.

2 of 3
6

For the past few hours I have been trying to find the difference between the 3, not just the difference, I also have been trying to find out which are sort of synonymous, MDN calls all declarations "statements", so I presume that is true.

A declaration is any construct that "declares" a variable name into existence at compile/load time before the program executes. All declared names in their respective scopes are therefore known in advance.

Statements and expressions differ from each other in that the former does not produce a value a result, whereas the latter does. So an expression may be used anywhere a value is expected, and a statement may not be used in those places.

An expression statement is one where the statement is a single expression, or several included in an expression that requires zero or more sub-expressions. While the expression(s) produce a result, the statement does not.

Here's an expression:

x = foo() + 2

A full expression statement could be explicitly shown by adding a semicolon to the end.

x = foo() + 2;

The first example can be wrapped in a set of parens, because the parens as a grouping operator expects an expression, often provided as several expressions joined by the comma operator.

The second example can not be wrapped in parens (if you include the semicolon) because then it is a statement, and does not produce a value, which the grouping operator expects to receive and return as its own value.

Something I have noticed with statements is that they all somehow involve a special JavaScript keyword like break or for or var.

While most statements do involve a keyword, not all do. Most notably, the block statement has no keyword. Instead it uses a set of curly braces to delimit its start and end.

The articles say that an expression evaluates to something, while a statement performs an action. What is a function then ? Is it a statement-expression hybrid (since it both performs an action when called, and returns a value) ? Right now, I am assuming that this is not the case since a function call does not involve a JavaScript keyword.

There are three kinds of functions in JS. If you're talking about the ones that use the function keyword, then the may be either a declaration or an expression depending on its context.

If the function is used where an expression would be expected, then it's evaluated as an expression that returns a new function object. If not, then it is expected to be a declaration, which basically creates a variable with the function object assigned to it. As a declaration, a function name is required (for the variable name). As an expression, it's optional.

I am also aware of expression statements like 20 + 5 * 2 / 3;, but aren't these virtually useless ? Why would anyone pollute their code with a line like this ?

If the resulting value is ignored, it would be useless, given that example. But here's another expression statement.

foobar();

Now we have a side effect from the function call, which is most likely desired and useful.

🌐
n8n
docs.n8n.io › code › expressions
Expressions | n8n Docs
Expressions are a powerful feature implemented in all n8n nodes. They allow node parameters to be set dynamically based on data from: ... You can also execute JavaScript within an expression, making this a convenient and easy way to manipulate data into useful parameter values without writing ...
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Statements › Expression_statement
Expression statement - JavaScript | MDN
JavaScript · Reference · Statements ... · Learn more · Deutsch · English (US) 日本語 · 中文 (简体) An expression statement is an expression used in a place where a statement is expected....