var myArray = [1, 2];
var valueToInsert = 1.5;
var indexToInsert = 1;
var deleteCount = 0;
myArray.splice(indexToInsert, deleteCount, valueToInsert);
console.log(JSON.stringify(myArray));
var valueToInsert = 1.5;
var indexToInsert = 1;
var deleteCount = 0;
myArray.splice(indexToInsert, deleteCount, valueToInsert);
console.log(JSON.stringify(myArray));
//outputs: [1, 1.5, 2]
No comments:
Post a Comment
Please provide any feedback or post questions here...