如何修复jslint'&&'子表达式应该包含在parens错误中 [英] how to fix jslint The '&&' subexpression should be wrapped in parens error
本文介绍了如何修复jslint'&&'子表达式应该包含在parens错误中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我把所有内容放在括号中但是下面的代码仍然在jslint中抛出错误:
I put everything in parentheses but code below still throws error in jslint:
Problem at line 5 character 104: The '&&' subexpression should be wrapped in parens.
if ((typeof (c1) === 'string') && (typeof (c2) === 'string') && (c1 !== n...
如何修复?
"use strict";
function t() {
var c1, c2;
if (((typeof (c1)) === 'string') && ((typeof (c2)) === 'string') && (c1 !== null) && (c2 !== null) && ((c1.trim()) === '') || ((c2.trim()) !== '')) {
return;
}
}
推荐答案
它抱怨表单 if(a && b&& c || d)
因为(我想),&&
或<是不是很明显code> || 将优先。修复它看起来像 if(a&& b&&(c || d))
,它将停止抱怨。
It's complaining about the form if(a && b && c || d)
because (I suppose) it's not immediately obvious whether &&
or ||
will take precedence. Fix it to look like if(a && b && (c || d))
and it will stop complaining.
这篇关于如何修复jslint'&&'子表达式应该包含在parens错误中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文