función Super simple:
function reindex_array_keys(array, start){
var temp = [];
start = typeof start == 'undefined' ? 0 : start;
start = typeof start != 'number' ? 0 : start;
for(var i in array){
temp[start++] = array[i];
}
return temp;
}
testArray = reindex_array_keys(testArray);
Nota: esto va a soplar las teclas personalizables. el resultado siempre estará indexado numéricamente. podrías agregar cheques para si es una matriz o no, pero tiendo a no usar funciones que construyo aparte de las que están destinadas a ser usadas. también puede iniciar el índice más alto si te gusta:
testArray = reindex_array_keys(testArray, 3);
que producirá artículos 3 'definido' al comienzo de la matriz. luego puede agregarlo, pero creo que sería mejor hacer primero testArray.unshift('newValue')
y reindexar personalmente.
divertirse
hacer lo que la matriz? – WarrenFaith
Probablemente quiera reindexar la matriz, a juzgar por su violín. –
@warren; en mi ejemplo, las teclas de matriz son 3, 7, 13. Cuando las serialicé, se convirtió en ",,, qwerty ,,,, asdfgh ,,,,,, zxcvbn". Lo que quiero es "qwerty, asdfgh, zxcvbn". – borayeris