- The element removed can be returned directly using return arr.shift();
- console.log() 方法用于在控制台输出信息 注意:它并不是返回值的语法
- pop-push 末尾进出
- shift-unshift开头进出
function nextInLine(arr, item) {
// 只修改这一行下面的代码
arr.push(item);
return arr.shift();
// 只修改这一行上面的代码
}
// 设置
const testArr = [1, 2, 3, 4, 5];
// 显示代码
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6));
console.log("After: " + JSON.stringify(testArr));