function Stack() {
this.items = [];
Stack.prototype.push = function (element) {
this.items.push(element);
}
Stack.prototype.pop = function () {
return this.items.pop();
}
Stack.prototype.size = function () {
return this.items.length;
}
Stack.prototype.isEmpty = function () {
return this.items.length === 0;
}
Stack.prototype.peek = function () {
return this.items[this.items.length-1];
}
Stack.prototype.toString = function () {
let result = ''
for (let i = 0; i < this.items.length; i++){
let sign = this.items.length-1 === i ? '':','
result += this.items[i] + sign;
}
return result;
}
}
let stack = new Stack();