Stack implementation in JS
JavaScript
class Stack {
constructor() {
this.data = [];
}
push(record){
this.data.push(record);
}
pop() {
return this.data.pop();
}
peek() {
return this.data[this.data.length - 1];
}
}
class Stack {
constructor() {
this.data = [];
}
push(record){
this.data.push(record);
}
pop() {
return this.data.pop();
}
peek() {
return this.data[this.data.length - 1];
}
}