Program to toggle K | Function to toggle the kth bit of n ; Driver code
function toggleBit ( n , k ) { return ( n ^ ( 1 << ( k - 1 ) ) ) ; } var n = 5 , k = 2 ; document . write ( toggleBit ( n , k ) ) ;