how to swap two objects in an array javascript code example Example: javascript swap array elements var b = list[y]; list[y] = list[x]; list[x] = b;