Edit in JSFiddle

var data, data_queue = [1, 2, 3, 4, 5];

function fetch() { return data_queue.shift(); }
function process(data) { $('body').append("<li>"+data+"</li>"); }

/*
The single equals is intentional. 
The fetch() method is invoked and the result is returned and assigned to 'data'.
Assignment expressions themselves also evaluate to a value in JavaScript: they return the assigned value itself.
Thus, when fetch() returns a falsy value, the while loop is exited.
*/

while(data = fetch()){
    process(data);
}