When I use the splice method to add elements to an array at a specified index, I find myself creating a null array first in order to achieve this. If I use an empty array instead, the elements do not get pushed to the specific instance that I intended. Currently, my workaround involves creating an empty array and pushing null values into it. I am curious if there is a different approach that can accomplish the same result.
This is how I'm currently handling it:
arr:any[];
for(let i=0;i<userDefinedLength;i++)
{
arr.push(null);
}