javascript - 为什么这个函数会从 JSLint 收到警告消息?
问题描述
我有一个运行良好的函数,但我仍然收到来自 JS Lint 的警告消息。
function undoActionClick() {
if (history.length <= 1) return;
history.pop();
contextTmp.putImageData(history[history.length - 1], 0, 0);
updateHistorySelection();
}
这是警告信息:Expected '{' and instead saw 'return'
。代码中是否存在明显错误,还是应该忽略该消息?
解决方案
function undoActionClick() {
if (history.length <= 1) {
return;
}
history.pop();
contextTmp.putImageData(history[history.length - 1], 0, 0);
updateHistorySelection();
}
这应该没问题,这不是您的代码错误,而是JSLint
.
文档中的更多信息
推荐阅读
- javascript - 导出到 csv JS 库 - 标题后没有空行
- python - Pandas dataframe join,通过groupby的计算过程(累积加权平均)
- php - PHP运算符之间的区别
- java - 在可配置的同步和异步模式下工作的 java 方法的返回值
- facebook - 无法通过 graph-api 将 Facebook 照片发布到群组和页面
- python - Datefinder.find_dates 会抛出文本中任何数字的日期,但“strict=True”不起作用
- java - java HttpClient 异步错误处理
- javascript - 将所选选项显示为 Html 和 JavaScript 中的引导下拉菜单
- javascript - 如何知道它是改变的道具还是 useEffect 中的内部状态
- docker - 在 Docker 中保护私有 PyPi 的凭据