Sunday, 18 August 2013

Why .slice always delete the last element

Why .slice always delete the last element

In the javascript, there are two arrays:tags[] and tags_java[]. I use
.splice to delete certain items, which of the same index in the two
arrays. The tags[] works fine, but tags_java doesn't, it seems always
delete the last item. here is the javascript and the jsfiddle link.
var tag = $(this).text();
var index = $.inArray(tag, tags);
tags.splice(index,1);
tags_java.splice(index,1);

No comments:

Post a Comment