语法错误:意外的标记“?" [英] SyntaxError: Unexpected token '?'

查看:57
本文介绍了语法错误:意外的标记“?"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

错误:

SyntaxError: Unexpected token '?'

这是代码:

const result1 = (null || undefined) ?? 'OK'; 
console.log(result1); // 'OK'

当我在 Node.js

推荐答案

<ECMAScript 2020 中新增了em>空合并运算符a>,2020 年 6 月(截至原始问题日期大约六个月前).

The nullish coalescing operator was newly added in ECMAScript 2020, in June 2020 (about six months ago as of the date of the original question).

如果您在代码中使用 ECMAScript 2020 功能,请确保使用完全实现 ECMAScript 2020 的 ECMAScript 实现(或至少是您正在使用的功能).

If you are using ECMAScript 2020 features in your code, make sure you use an ECMAScript implementation that fully implements ECMAScript 2020 (or at least the features you are using).

这篇关于语法错误:意外的标记“?"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆