Binary representation of a given number | bin function ; Driver Code
function bin ( n ) { let i ; document . write ( " " ) ; for ( i = 1 << 30 ; i > 0 ; i = Math . floor ( i / 2 ) ) { if ( ( n & i ) != 0 ) { document . write ( " " ) ; } else { document . write ( " " ) ; } } } bin ( 7 ) ; document . write ( " " ) ; bin ( 4 ) ;