js swap 2 array indexes code example Example: javascript switch items in array var b = list[y]; list[y] = list[x]; list[x] = b;