JS (ts) based review (a) a stack data structure

Here Insert Picture Description
Eat spit is the stack, eat pull a queue

Stack is last out
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description

class Stack{
  private items:number[] = []
  push(element:number){
    this.items.push(element);
  } //进栈
  pop():number{
    return this.items.pop()
  }//出栈
}
let stack = new Stack();
stack.push(1);
stack.push(2);
stack.push(3);
console.log(stack.pop());
console.log(stack.pop());
console.log(stack.pop());

// 2.代码结构的运行方式
function one(){
  function two(){
    function three(){
      debugger

    }
    three();
  }
  two();

}
one();
Published 98 original articles · won praise 4 · views 20000 +

Guess you like

Origin blog.csdn.net/weixin_42416812/article/details/105292324