Quick actions

cmd+k|ctrl+k

Navigation

Languages

Stack

Snippet info

Language

JavaScript

Visibility

public

Author

cliffharvey06

Created

2025-11-14T22:10:16.891609Z

Updated

2025-11-14T22:28:43.804387Z

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