class Stack {
constructor() {
this.data = [];
}
peek() {
if(this.data.length === 0) return '';
return this.data[this.data.length-1];
}
pop() {
if(this.data.length === 0) return;
return this.data.pop()
}
push(value) {
this.data.push(value);
return this
}
}
const stack = new Stack();
stack.push('mail.ru'); // 1
stack.push('yandex.ru'); // 2
stack.push('wb.ru'); // 3
console.log(stack.peek());
stack.pop();
stack.pop();
stack.pop();
console.log(stack.peek());