Quick actions

cmd+k|ctrl+k

Navigation

Languages

Implementation of Stack using Arrays

Snippet info

Language

JavaScript

Visibility

public

Author

dhamankovachi1

Created

2023-11-06T08:25:02.093984Z

Updated

2023-11-06T08:25:02.093984Z

class Node {
  constructor(value){
    this.value = value;
    this.next = null;
  }
}

class Stack {
  constructor(){
    this.array=[]
  }
  peek() {
    return this.array[this.array.length-1];
  }
  push(value){
    this.array.push(value);
    return this;
  }
  pop(){
    this.array.pop();
    return this;
  }
  //isEmpty
}

const myStack = new Stack();
myStack.peek();
myStack.push('google');
myStack.push('udemy');
myStack.push('discord');
myStack.pop();


//Discord
//Udemy
//google
INFO