8
rated 0 times
[
11]
[
3]
/ answers: 1 / hits: 18171
/ 10 Years ago, wed, april 30, 2014, 12:00:00
I have following code:
var a = [{a: 1}, {a: 2}, {a: 3}];
a.map(function (item, index) {
console.log('call');
if (index < 1) {
a.splice(index, 1);
}
});
But call is printed only two times, and I expect to be printed three times. I know that splice
has messed up array, but is there some workaround for this behaviour?
Thank you!
More From » splice