为什么jshint无法将赋值识别为表达式? [英] Why does jshint not recognize an assignment as an expression?

查看:71
本文介绍了为什么jshint无法将赋值识别为表达式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何修改这些行以使jshint开心?

How do I need to modify these lines to make jshint happy?

赋值是一个表达式. jshint为什么不理解这一点?显然,口译员可以.

An assignment is an expression. Why doesn't jshint understand this? Obviously the interpreter does.

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.

推荐答案

如果您确实想收听JSHint,请通过以下方式将表达式转换为布尔值:

If you really want to listen to JSHint, convert the expression to a boolean by:

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.

因此,!!的意思是:将某些内容转换为条件表示.

So, !! means: Convert something to the conditional representation.

这篇关于为什么jshint无法将赋值识别为表达式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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