swap two elements in array angularjs code example Example: swap elements in array typescript [elements[0], elements[3]] = [elements[3], elements[0]];