Get to know MDN better
The JavaScript exception "await expression can't be used in parameter" or "yield expression can't be used in parameter" occurs when the default parameter expression contains the await or yield keyword and has the effect of pausing default parameter evaluation.
The default expression must be able to evaluate synchronously. If it contains an await or yield expression, it will pause the evaluation of the default expression, which is not allowed.
Note: This error is only generated when await or yield are valid operators in this function context. Otherwise, await or yield would be parsed as an identifier, and either not cause an error, or cause an error like "reserved identifier", or "unexpected token" if there's an expression following it.
You can use the nullish coalescing assignment to provide a default value instead. If you want to treat null and undefined differently, you would need to use a condition.
You are also allowed to use await or yield if the expression is contained in a function expression of the initializer and would not pause the evaluation of the default expression.
This page was last modified on Jul 8, 2025 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.