For example:
var frutas = ["goiaba", "manga", "laranja", "abacate"];
frutas.splice(1, 1);
This code, instead of removing 1 item from the second index of my array (1), only returns the item I want to delete, which in this case is "orange";
That is, instead of returning ["goiaba", "manga", "abacate"]
- it returns ["laranja"]
;
As I understood what I read / researched, Array.prototype.splice()
serves to do what I'm trying to do. Am I right? If yes, why is this behavior of the splice
method?
NOTE: Google Chrome browser version 60