Utility Methods
Push

A method used to add one or more elements to the end of an array. It modifies the original array, increasing its length, and returns the new length of the array. This operation is efficient for dynamically expanding arrays and simplifies the process of appending elements.

Pop

Removes the last element from an array, reducing its length by 1. The removed element is returned, and the original array is modified. This operation is useful for efficiently removing elements from the end of an array, making it a straightforward way to manage dynamic arrays.

Shift

Removes the first element from an array, shifting all other elements down by one position. The removed element is returned, and the original array is modified. This operation is handy for efficiently removing elements from the beginning of an array, resulting in a re-indexing of the remaining elements.

Unshift

Adds one or more elements to the beginning of an array. It modifies the original array, shifting existing elements to higher indexes, and returns the new length of the array. This operation is useful for efficiently prepending elements to an array, making it a convenient way to insert elements at the beginning.

Splice

Used to add, remove, or replace elements in an array. It modifies the original array and returns an array containing the removed elements, if any. The method takes multiple parameters, allowing you to specify the starting index, the number of elements to remove, and the elements to add.

Slice

Returns a shallow copy of a portion of an array, specified by providing starting and ending indices. The original array remains unchanged. This method is useful for creating a subset of an array without modifying the original, providing a convenient way to work with specific sections of the array.

Array Search
Linear

Iterates through a list to find a target by comparing each element sequentially. Its simplicity allows easy implementation, but with a time complexity of O(n), it becomes less efficient for larger datasets. For optimal performance on extensive lists, more advanced algorithms like binary search are preferred over the linear search approach.

Binary

Binary search is an efficient algorithm for finding a target value in a sorted array. It repeatedly divides the array in half, comparing the target with the middle element. If the target is equal, the search is successful. If the target is smaller, it narrows the search to the lower half; if larger, to the upper half. This process continues until the target is found or the subarray is empty. Binary search has a time complexity of O(log n), making it significantly faster than linear search for large datasets, showcasing its effectiveness in sorted collections.