JSLint:预期为"!!"而是看到了“?" [英] JSLint : Expected '!!' and instead saw '?'

查看:123
本文介绍了JSLint:预期为"!!"而是看到了“?"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在问号中出现错误.这是代码

I am getting the error in the question mark. Here is the code

var isParallelStage = ($("#workflowStagesList .workflowStageListItemActive").find("p").text() === "P") ? true : false;

错误:

JSLint:预期为"!!"而是看到?".

JSLint : Expected '!!' and instead saw '?'.

推荐答案

? true : false是一种反模式-完全没有用,它是一个身份函数,您可以简单地忽略它,您已经有一个布尔值.如果没有,则应使用!!Boolean(…)将值转换为布尔值.

? true : false is an antipattern - it's totally useless, an identity function, you can simply omit it, you've already got a boolean. And if you didn't, you should use !! or Boolean(…) to cast your value to a boolean.

这篇关于JSLint:预期为"!!"而是看到了“?"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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