Skip to content

SyntaxError: Missing parenthesis 之后实参列表

错误信息

                Missing parenthesis 之后实参列表
              

快速摘要

你 called 函数但 forgot 到关闭 parentheses, 所以 JavaScript cannot parse call.

为什么发生

  • Forgot 关闭) 当 calling 函数

  • Mismatched parentheses in 复杂表达式

  • 复制 code 那个是 不完整

最小示例

✗ 错误代码
console.log("hello";
✓ 修复代码
console.log("hello");

关闭) 是 missing 之后实参. 添加它 completes call.

如何诊断

  • Look at 行 mentioned in 错误 for unclosed parenthesis

  • 数量打开 and 关闭 parentheses — 它们应该 match

  • Use editor 使用 bracket matching 到查找 unclosed pair

如何修复

  • 添加 missing 关闭 parenthesis

  • Balance 所有 parentheses in 表达式

  • 运行 code 通过 formatter (Prettier) 到 spot 结构 issues

如何预防

  • Use editor 使用 bracket matching and 语法 highlighting

  • 运行 linter 到 catch 语法错误 as 你类型

相关资源

相关术语

相关课程

  • 函数

    学习关于函数 calls.

← 返回语言