gpt4 book ai didi

javascript - 错误: expected an assignment or function call and instead saw an expression

转载 作者:行者123 更新时间:2023-11-28 19:25:14 29 4
gpt4 key购买 nike

booking.save(function (error, data) {
error ? console.log(error) : res.redirect('/');
});

此代码导致 Sublime Text 中显示以下错误:

Expected an assignment or function call and instead saw an expression

这是为什么呢?我的代码有什么问题吗?它正在 100% 工作。我没有看到错误。

最佳答案

JSLint error不是 JS 错误。

在您的情况下,它认为三元运算符应该仅用于赋值,例如

var foo = bar ? 2 : 3;

由于没有赋值 JSLint 认为该字符串无用。将其更改为 if-else block 或使用具有适当设置的 JSHint。

关于javascript - 错误: expected an assignment or function call and instead saw an expression,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28013368/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com