class Stack < T > { data : Array < T > ; top : number ; constructor ( ) { this . data = [ ] ; this . top = 0 ; } public push ( item ) { this . data . push ( item ) ; this . top ++ ; } public pop ( ) { this . top -- ; return this . data . pop ( ) ; } public peek ( ) { return this . data [ this . top - 1 ] ; } public isEmpty ( ) { return this . top === 0 ; } public size ( ) { return this . top ; } public clear ( ) { delete this . data ; this . top = 0 ; this . data = [ ] ; } public print ( ) { console . log ( this . data . toString ( ) ) ; } } export default Stack ;