Consider the array variable below...
var fruits = [];
fruits.push("banana");
fruits.push("apple");
fruits.push("mango");
fruits.push("orange");
fruits.push("grapes");
We should have these values...
fruits[0]=>"banana"
fruits[1]=>"apple"
fruits[2]=>"mango"
fruits[3]=>"orange"
fruits[4]=>"grapes"
Say I have a pointer and it's currently at number 2, so the current value is mango, how do I overwrite orange and grapes when I do another push? Is it possible? Say I wanted to add coconut but I don't want it assigned to fruits[5], what I would like to have is orange getting replaced with coconut and it goes on and on... How do I achieve this? Thank you.
.splice()