why does array.shift skip a value?
I have this function
$(this).each(function(index) {
arr[index] = ($(this).attr('id'));
console.log(arr[index]);
fullId[index] = "开发者_如何学JAVA#"+arr.shift();
console.log(fullId[index]);
});
The results I'm expecting are
A
#A
B
#B
C
#C
D
#D
The actual results are
A
#A
B
Undefined
C
#B
D
Undefined
Why is this?
You realize that shift
ing arr
changes the indexes of all items in the array, right?
And yet won't affect $(this)
at all?
精彩评论