I attempted to eliminate an element from an array by utilizing the indexOf()
combined with the splice()
method as recommended. However, the outcome is not as expected.
let someArray: string[] = [first, second, third, fourth, fifth, sixth];
let newArray: string[] = someArray.splice(3, 1);
console.log(newArray);
//desired output = [first, second, third, fifth, sixth]
//actual result = [fourth]
This does not align with the information provided in most articles I have come across. Can anyone provide clarification on this issue?
UPDATE I encountered this discrepancy in my code when I received only a single result instead of the expected multiple results, leading me back to this particular point.