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

偶尔善良 提交于 2019-12-12 05:59:14

问题


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

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

Error:

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


回答1:


? 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.



来源:https://stackoverflow.com/questions/36770789/jslint-expected-and-instead-saw

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!