SOURCE

var Queue = function(){
  var items = [];
  //入队
  this.enqueue = function(element){
    items.push(element);
  }
  //出队
  this.dequeue = function(element){
    return items.shift(); //拿走第一个元素
  }
  //返回第一个元素
  this.front = function(){
    return items[0];
  }
  //是否是空
  this.isEmpty = function(){
    return items.length === 0;
  }
  //清除队列
  this.clear = function(){
    items = [];
  }
  //队列大小
  this.size = function(){
    return items.length;
  }
  this.print = function(){
    console.log(items.toString());
  }
}
console 命令行工具 X clear

                    
>
console