Reference Splice

  • method adds and/or removes array elements.
  • method overwrites the original array!
  • This is important to remember that the add does add if 0 in second parameter, if greater than 1 it will delete before adding.
  • W3Schools Documentation Array Splice

Example - None just look at the code.
WDS Video on this Hook
fetch("https://jsonplaceholder.typicode.com/todos") .then((response) => response.json()) .then((todos) => { // Add to array todos.splice(1, 0, { title: "test" }); console.log(todos); // // remove from array // todos.splice(1, 1); // console.log(todos); });