.top()
Christine_Yang271 total contributions
Published Jul 29, 2022Updated Dec 21, 2022
Contribute to Docs
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
- Christine_Yang271 total contributions
- garanews222 total contributions
- StevenSwiniarski474 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.