queue.js 588 Bytes
"use strict";

function Queue (){
  this.arr = new Array();
  this.leng = 0;
  this.push = push;
  this.pop = pop;
}

function push(x) {
    this.arr[this.leng++] = x;
}

function pop (){
  var ret;
  ret = this.arr[0];

  for (var i = 0 ; i < this.leng; i++){
    this.arr[i] = this.arr[i+1];
  }
  this.leng--;

  return ret;
}

var queue = new Queue();
queue.push(1);
queue.push(2);
queue.push(3);
queue.push(4);
queue.push(5);

console.log(queue.pop());
console.log(queue.pop());
console.log(queue.pop());
console.log(queue.pop());
console.log(queue.pop());
console.log(queue.pop());