insert element at a position js

Solutions on MaxInterview for insert element at a position js by the best coders in the world

showing results for - "insert element at a position js"
Dusty
23 Oct 2020
1var arr = [];
2arr[0] = "Jani";
3arr[1] = "Hege";
4arr[2] = "Stale";
5arr[3] = "Kai Jim";
6arr[4] = "Borge";
7
8console.log(arr.join()); // Jani,Hege,Stale,Kai Jim,Borge
9arr.splice(2, 0, "Lene");
10console.log(arr.join()); // Jani,Hege,Lene,Stale,Kai Jim,Borge