Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Stack {
- private _data: number[] = [];
- public peek(): number {
- return this._data[this._data.length - 1];
- }
- public push(element: number): void {
- this._data.push(element);
- }
- public pop(): number {
- return this._data.pop();
- }
- }
- const myStack = new Stack();
- myStack.push(1);
- myStack.push(2);
- myStack.push(3);
- console.log(myStack.peek());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement