In | An in - place Javascript program to reverse an array ; Function to reverse arr [ ] from start to end ; Utility function to print an array ; Driver code
function __ ( x , y ) { return x ; } function revereseArray ( arr , n ) { for ( let i = 0 ; i < n / 2 ; i ++ ) arr [ i ] = __ ( arr [ n - i - 1 ] , arr [ n - i - 1 ] = arr [ i ] ) ; } function printArray ( arr , size ) { for ( let i = 0 ; i < size ; i ++ ) document . write ( arr [ i ] + " " ) ; document . write ( " " ) ; } let arr = [ 1 , 2 , 3 , 4 , 5 , 6 ] ; let n = arr . length ; printArray ( arr , n ) ; revereseArray ( arr , n ) ; document . write ( " " ) ; printArray ( arr , n ) ;