I'm working with some JS code that I inherited on a project, and in several instances it has loops set up like this one:
while(text = someBufferObject.read()) {
//do stuff with text
}
I'm assuming this is to achieve some sort of do-while type functionality. However, when I run this through JSLINT it complains that it "Expected a conditional expression and instead saw an assignment."
Is there a more accepted approach that I should use for these loops? I'm not sure if something like below is the best way or not:
text = someBufferObject.read()
while(text) {
//do stuff with text
text = someBufferObject.read()
}