错误:
SyntaxError: Unexpected token '?'
代码如下:
const result1 = (null || undefined) ?? 'OK';
console.log(result1); // 'OK'
当我在 Node.js
中运行这个程序时,它引发了意外的 token 错误
最佳答案
nullish coalescing operator新加入ECMAScript 2020 ,2020 年 6 月(从原始问题提出之日起大约六个月前)。
如果您在代码中使用 ECMAScript 2020 功能,请确保您使用的 ECMAScript 实现完全实现了 ECMAScript 2020 (or at least the features you are using)。
关于javascript - 语法错误 : Unexpected token '?' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65396855/