Push
Push is an operation that inserts an item into a collection at its defined insertion end, such as the top of a stack or the end of an array.
Fabulous Adventures in Data Structures and Algorithms
Push is a linked-list operation that adds a value to the front of a list and returns the resulting list.
- How it is used
- Uses push to construct immutable linked lists and stacks, prepend values, and build new versions without mutation.
- How deep it goes
- Defines the operation, implements it with a new head and shared tail, and connects it to reversal and covariance.
- Examples
- Uses chained integer pushes, stack versions, list reversal, and animal values pushed through a covariant stack.
- What you can do after
- Build it from scratch in C# as a constant-time immutable prepend operation returning a new list or stack.
Read how Fabulous Adventures in Data Structures and Algorithms explains push →
The Well-Grounded Rubyist, Fourth Edition
Array#push is a Ruby Array method that appends one or more objects to the end of an array.
- How it is used
- Appends objects to an array’s end, including several objects in one operation.
- How deep it goes
- Defines single- and multiple-argument use, contrasting push with << and related array-end methods.
- Examples
- Demonstrates appending one object and appending three objects to arrays containing integers.
- What you can do after
- Apply it via Ruby’s Array API to append one or several objects at an array’s end.
Read how The Well-Grounded Rubyist, Fourth Edition explains push →
Secrets of the JavaScript Ninja, Second Edition
An Array method that appends one or more elements and returns the new length.
- How it is used
- Uses push to append elements to an array’s end and demonstrates reusing it on an array-like object.
- How deep it goes
- Explains end-appending, length changes, relative performance, and borrowing via call, but leaves push’s return value unspecified.
- Examples
- Uses a ninja array to show appending and a browser-element object to demonstrate borrowing push.
- What you can do after
- Apply push to append array elements or invoke Array.prototype.push.call on an object with a length property.
Read how Secrets of the JavaScript Ninja, Second Edition explains push →
Grokking Data Structures
A push method is a stack operation that adds an element to the top of the stack.
- How it is used
- Adds elements to a stack while maintaining its top-based, last-in, first-out interface.
- How deep it goes
- Explains top insertion, linked-list delegation, and optional validation without detailing lower-level storage mechanics.
- Examples
- Uses a pile of dishes, a linked-list wrapper, and rejection of empty strings as concrete illustrations.
- What you can do after
- Build it by forwarding insertion to a linked list and adding domain-specific checks before storage.
Also covered in
- Julia as a Second Language
- Systems Programming with ZigIn early access (MEAP)
- Grokking Simplicity
- Secrets of the JavaScript Ninja, Third EditionIn early access (MEAP)
- Latency
What to know first
- arrayAn array is an ordered collection of elements organized in one or more dimensions and accessible by position or index.
- linked listAn ordered sequence of elements stored in separate nodes connected by links or references rather than in one contiguous storage region.
- stackA stack is a last-in, first-out data structure in which elements are added and removed at the same end.
Related concepts
- arrayuses · An array is an ordered collection of elements organized in one or more dimensions and accessible by position or index.
- stackpart of · A stack is a last-in, first-out data structure in which elements are added and removed at the same end.
- concatenationcontrasts with · Concatenation is the operation of joining ordered sequences end to end, or along a specified dimension, to form a combined sequence or structure.
- shiftcontrasts with · Array.prototype.shift is a JavaScript array method that removes and returns the first element, mutating the array.
Questions about push
What is push?
Push is an operation that inserts an item into a collection at its defined insertion end, such as the top of a stack or the end of an array.
Which Manning books explain push?
Fabulous Adventures in Data Structures and Algorithms, The Well-Grounded Rubyist, Fourth Edition, Secrets of the JavaScript Ninja, Second Edition and Grokking Data Structures.
What should I know before learning push?
Manning books that teach push usually introduce array, linked list and stack first.
What is the difference between push and Array#[]?
Push is an operation that inserts an item into a collection at its defined insertion end, such as the top of a stack or the end of an array. Array#[] is Ruby's Array element-access method, retrieving values at specified indexes, ranges, or index-length spans.
What is push part of?
Push is part of stack. A stack is a last-in, first-out data structure in which elements are added and removed at the same end.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.



