function Stack() {
this.list = []
}
Stack.prototype.push = function (item) {
this.list.push(item)
}
Stack.prototype.pop = function () {
return this.list.pop()
}
Stack.prototype.peek = function () {
return this.list[this.list.length - 1]
}
Stack.prototype.isEmpty = function () {
return this.list.length > 0
}
Stack.prototype.clear = function () {
this.list.length = 0
}
Stack.prototype.size = function () {
return this.list.length
}
Stack.prototype.print = function () {
console.log(this.list.join(','))
}
let stack = new Stack()
console.log(stack.isEmpty())
stack.push(1)
stack.push(2)
stack.push(3)
stack.push(4)
console.log(stack)
console