I have an array like the following
const inputArray = [
{
_id: "D01",
name: "Sky",
},
{
_id: "D02",
name: "Space",
},
{
_id: "D03",
name: "Black",
},
{
_id: "D04",
name: "Yello",
},
];
How to write a function so that I can insert another object say,
const dataToBeInserver = {
_id: "A01",
name: "Watch",
};
to a specified index, lets say at index 2. Thanks!