SOURCE

function Node(str){
  this.pre = null
  this.next = null
  this.content = str
}

var HEAD = new Node('head')

function push(node){
  
  var last = HEAD
  while(last.next){
    last = last.next
  }
  
  node.pre = last
  last.next = node
}

function shift(){
  var node = null
  node = HEAD.next
  
  HEAD.next = node.next
  node.next.pre = HEAD
  
  node.pre = null
  node.next = null
  
  return node
}

push(new Node('1'))
push(new Node('2'))


function printArr(){
  var curr = HEAD.next
  while(curr){
    console.log(curr.content)
		curr = curr.next
  }
}

printArr()


console 命令行工具 X clear

                    
>
console