mirror of
https://github.com/microsoft/frontend-bootcamp.git
synced 2026-03-26 19:56:44 +08:00
14 lines
195 B
TypeScript
14 lines
195 B
TypeScript
export class Stack<T> {
|
|
private _items: T[] = [];
|
|
|
|
push(item: T) {
|
|
this._items.push(item);
|
|
}
|
|
|
|
pop(): T {
|
|
if (this._items.length > 0) {
|
|
return this._items.pop();
|
|
}
|
|
}
|
|
}
|