.top()
The .top()
method returns the top element on the stack
. This will be the most recently added element on the stack
since they follow a last-in first-out (LIFO) insertion order.
Syntax
The .top()
method can be called on a stack
using the following syntax:
stackName.top();
Codebyte Example
The following example calls the .top()
method to print successive entries from myStack
:
All contributors
- garanews209 total contributions
- StevenSwiniarski466 total contributions
- Christine_Yang265 total contributions
Looking to contribute?
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.