1

When I have stored the values in an array,

const greens = [
  { name: "cedar", count: 2 },
  { name: "fir", count: 6 },
  { name: "pine", count: 3 }
];

var greensSplice = greens.splice(0,1);

when I splice to remove the initial index value and change the position of the index, I wish to get the removed index value

3
  • what should be the expected result here? You should add in the question itself... Commented Nov 27, 2022 at 6:32
  • The first argument you pass to splice is the index at which the element(s) are to be removed or added. So if you do splice(1, the index at which you're removing is 1. So either repeat the 1 or save it in a variable. Commented Nov 27, 2022 at 6:37
  • 1
    i understood your question using, it's very simple, Just check the console on greenSplice After you get this value [ { name: "fir", count: 6 }, { name: "pine", count: 3 } ] Commented Dec 1, 2022 at 6:11

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.