dropNew
dropNew is a JavaScript function designed to remove the last element from an array. It achieves this by creating a new array that includes all elements of the original array except for the final one. This approach ensures that the original array remains unmodified, adhering to functional programming principles of immutability. The function can be implemented using the `slice()` method, which returns a shallow copy of a portion of an array into a new array object. By slicing from the beginning of the array up to, but not including, the last element, `dropNew` effectively excludes the last item. For instance, if an array `[1, 2, 3]` is passed to `dropNew`, the function would return a new array `[1, 2]`. This method is useful in scenarios where preserving the original data structure is important, such as in state management within JavaScript frameworks or when performing complex data transformations. It avoids side effects by not altering the array in place.