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

maranR
  • 363
  • 8
  • what should be the expected result here? You should add in the question itself... – DecPK Nov 27 '22 at 06: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. – CertainPerformance Nov 27 '22 at 06: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 } ] – R sukumar Dec 01 '22 at 06:11

0 Answers0