// Insert value at specific position with loop.
const data = [32, 1, 43, 76, 87]
const position = 2
let newValue = 69
for (let i = data.length - 1; i >= 0; i--) {
if (i >= position) {
data[i + 1] = data[i]
if (i === position) {
data[i] = newValue
}
}
}
console.log("===> :: data", data)
myArray.splice(index, 0, item);
const sidebarMenu = ['home', 'about', 'contact'];
sidebarMenu.splice(2, 0, 'courses'); //Add Single Element
sidebarMenu.splice(2, 0, 'courses', 'profile'); //Add Multiple Elements
var arr = [];
arr[0] = "Jani";
arr[1] = "Hege";
arr[2] = "Stale";
arr[3] = "Kai Jim";
arr[4] = "Borge";
console.log(arr.join());
arr.splice(2, 0, "Lene");
console.log(arr.join());
const numbers = ['one', 'two', 'four', 'five']
numbers.splice(2, 0, 'three'); // one,two,three,four,five