Stack

Stack

A stack with some extra error handling. Items stored in the stack can have any type.

Constructor

new Stack()

Source:

Members

length :number

Properties:
Name Type Description
Returns number

the number of items in the stack

Source:
Type:
  • number

Methods

bottom(offsetopt) → {*}

Returns an item relative to the bottom of the stack

Source:
Parameters:
Name Type Attributes Default Description
offset number <optional>
0

An index relative to the bottom of the stack. 0 for the bottom of the stack; 1 for the item above the bottom of the stack; 2 for the second item above the bottom of the stack; etc..

Returns:
Type:
*

clear()

Removes all items. This is the same as pop(0).

Source:

pop(toLengthopt) → {*|undefined}

Removes items from the top of the stack

Source:
Parameters:
Name Type Attributes Description
toLength number <optional>

If undefined, remove the item at the top of the stack only. Otherwise, remove items from the top of the stack until its length is equal to the specified value.

Returns:
Type:
* | undefined

The last item removed from the stack

push(item) → {number}

Adds an item to the top of the stack

Source:
Parameters:
Name Type Description
item *
Returns:
Type:
number

The new length of the stack

top(offsetopt) → {*}

Returns an item relative to the top of the stack

Source:
Parameters:
Name Type Attributes Default Description
offset number <optional>
0

An index relative to the top of the stack. 0 for the top of the stack; 1 for the item below the top of the stack; 2 for the second item below the top of the stack; etc..

Returns:
Type:
*