mishapod,
function nextInLine(arr, item) {
arr.push(item);
return arr.shift();
}
// Test Setup
var testArr = [1,2,3,4,5];
// Display Code
alert("Before: " + JSON.stringify(testArr));
alert(nextInLine(testArr, 6)); // Modify this line to test
alert("After: " + JSON.stringify(testArr));