at first let me explain want. well, have sorted array this
var arr = ["ab", "abcd", "abdf", "abcdd", "abcdd", "abcdfd", "abcdsss", "abcdefgh", "abcdsdsdsds"];
now need remove elements string length less 5. ok, point is, there easiest way find index of element string length 4. likes here 2 elements contain string length 4. need last one. if possible index can apply
arr.splice(0, (index+1));
and 1 thing, original array contain 1 million data. how can solve this?
you can use array filter remove elements.
var arr = ["ab", "abcd", "abdf", "abcdd", "abcdd", "abcdfd", "abcdsss", "abcdefgh", "abcdsdsdsds"]; arr = arr.filter(function(item) { return item.length > 4; }); //["abcdd", "abcdd", "abcdfd", "abcdsss", "abcdefgh", "abcdsdsdsds"]
i don't know how have 1 million items in array, maybe try reduce array in server before sending client. (i don't know data comes from, lot of data javascript array);
Comments
Post a Comment