Using the map function, I am adding elements to array arr1
. Is there a way to specify the starting index position in typescript
?
For example: If I want to add elements from the 3rd index position of the array, with the first two indices holding a value of 0, how can I achieve this?
let years = [0,1,2,3,4];
data = {
var1: 100000,
arr2: years.map(_ => 1000)
};
console.log(data.arr2);
I aim to have zeros added at the beginning of the array. By specifying the position as 3, the first two elements should be zero.