开发者

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 shifting arr changes the indexes of all items in the array, right?

And yet won't affect $(this) at all?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜