Array Power, Part II - DHTML Lab | 9
Array Power, Part II
using push() and pop()
push()
The push() method should be the one of the most-often used methods for your arrays. Use it to build an array and/or to append elements to it.
Stack
The terms push and pop are old programming terms used to describe actions taken on a stack. (See our previous column for a description of the stack concept and an interactive demo.)
Therefore, push (pushing a value onto a stack or array) and pop (popping, or pulling a value from the stack or array) were natural monikers for the new JavaScript methods.
Use them for building arrays that act as stacks.
In the final installment of this series, we'll look at the much more sophisticated splice() method and create a common behavior for both browsers across all versions. See ya then.
Produced by Peter Belesis and
All Rights Reserved. Legal Notices.Created: May 2, 2000
Revised: May 2, 2000
URL: https://www.webreference.com/dhtml/column32/9.html