Is there any way to retrieve the element that was most recently added/inserted to an array in Javascript?
To be crystal clear, I don't mean the last element in the array, I mean the element that was last inserted to some arbitrary position.
If there's no way of doing it without explicitly storing the last index upon insertion, then I'll look for the simplest answer based on that.
For those asking how the element was added, let's say I've done this:
// Insert new_element at index, shift other elements to accomodate it
existing_array.splice(index, 0, new_element);