19 javascript jshint
我如何修改这些行以使jshint满意?
赋值是一种表达.为什么jshint不理解这个?显然翻译是这样的.
Line 572: while(bookmark_element=bookmark_list[iterator++])
Expected a conditional expression and instead saw an assignment.
Line 582: while(bookmark_element=bookmark_list[iterator++])
Expected a conditional expression and instead saw an assignment.
Line 623: while(element_iterator=element_iterator.nextSibling)
Expected a conditional expression and instead saw an assignment.
Run Code Online (Sandbox Code Playgroud)
Rob*_*b W 20
如果你真的想听JSHint,请将表达式转换为布尔值:
while (!!(bookmark_element=bookmark_list[iterator++]))
! means: Something that evaluates to true is converted to false,
something that evaluates to false is converted to true.
Run Code Online (Sandbox Code Playgroud)
所以,!!意思是:将某些东西转换为条件表示.
Mar*_*ers 13
我确信jshint理解表达式很好,只是大多数人写的if (a = b)实际意味着if (a == b)所以这会产生警告.
由于您的代码是您想要的,您可以添加一个明确的测试:
while ((element_iterator = element_iterator.nextSibling) !== null) { ... }
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8815 次 |
| 最近记录: |