Stack

Stack

A Stack is a subclass of an Array that implements First In, Last Out ordering.

Constructor

new Stack()

Source:

Extends

  • Array

Methods

clear()

Source:
Clear the contents of the stack.

hasNext() → {boolean}

Source:
Checks if the stack isn't empty.
Returns:
Whether or not the stack has another element. True if yes.
Type
boolean

isEmpty() → {boolean}

Source:
Checks if the stack is empty.
Returns:
Whether or not the stack is empty. True if yes.
Type
boolean

peek() → {any}

Source:
Get the front element of the stack without removing it from the stack.
Returns:
Front element from the stack.
Type
any

size() → {number}

Source:
Get the number of objects in the stack.
Returns:
Number of elements in the stack.
Type
number