swap two elements in an array javascript lodash code example Example: switch element array angular [elements[0], elements[3]] = [elements[3], elements[0]];