Skip to content

Latest commit

 

History

History
19 lines (16 loc) · 277 Bytes

队列.md

File metadata and controls

19 lines (16 loc) · 277 Bytes

队列

遵循先进先出原则,从后面插入,前面删除

  class Queue {
    constructor() {
      this.items = []
    }

    push(value) {
      this.items.push(value)
      return this.items
    }

    shift() {
      return this.items.shift()
    }
  }