Quantcast
Channel: Latest Questions by limdingwen
Viewing all articles
Browse latest Browse all 18

Swapping elements of an array

$
0
0
Hello, how can I swap 2 elements of an array (the index)? The code I am using now is:

var temp = kartsRankingArray[o];
kartsRankingArray[o] = kartsRankingArray[o+1];
kartsRankingArray[o+1] = temp;

It works, but I am not sure. Won't this swap the contents of the objects instead of swapping the indexes of the objects in the array? Thanks! -- Leo ;)

Viewing all articles
Browse latest Browse all 18

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>