Whenever I do something like this...
var obj;
while (obj = doSomething()) {
// something with obj
}
JSHint tells me warning 84| Expected a conditional expression and instead saw an assignment.
. However, doing obj = doSomething()
returns the value that doSomething()
returns during assignment, so it makes sense to write a while loop in this fashion.
Is there a specific reason that JSHint warns me, and more importantly, are there reasons to not do this? Or can I tell JSHint to ignore those lines for that specific warning?