Reputation: 3293
Is there a way to give a specific index, in an array, a value. In PHP, I could just do this $arr[index] = val;
Right now, I use
Array.prototype.insert = function (index, item) {
this.splice(index, 0, item);
};
And
var mute = [];
mute.insert(index, 'value');
But, if the array is empty, the index will still be 0. How do I get the right index?
Upvotes: 0
Views: 1100