00:00 A stack is a last-in/first-out data structure with key operations having a time complexity of O(1). We can model this easily in TypeScript using the generic class for items of type T.
00:22 The stack data structure has two key operations. The first one is push, which adds an item in O(1). The other key operation pops an item from the stack, again in O(1). If there are no more items, we can return an out-of-bound value, for example, undefined. This fact can be modeled into the type system by using a union of T and undefined.
01:18 Therefore, we can simply implement the operations of this data structure using an array. On push, we simply push the new item into the array. As it doesn't change the index of the current items, this is O(1). Similarly, on pop, we simply pop the last value from the array. Again, it doesn't change the index of the other items in the array, so it is O(1).