Mark As Completed Discussion

There are auxiliary methods like top(), or sometimes called peek(), which are built-in functions that give you the value of what's on top of the stack. Here the top() function calls top.data which refers to the value inside of a node.

In the isEmpty() method, top is being compared to null. This is being done to check whether there is a value in the stack, or the stack is empty.

Attached is the full implementation of a stack using a linked list under the hood.

JAVASCRIPT
OUTPUT
:001 > Cmd/Ctrl-Enter to run, Cmd/Ctrl-/ to comment