Highest power of 2 less than or equal to given number | Javascript program to find highest power of 2 smaller than or equal to n . ; Driver code
function highestPowerof2 ( n ) { let p = parseInt ( Math . log ( n ) / Math . log ( 2 ) , 10 ) ; return Math . pow ( 2 , p ) ; } let n = 10 ; document . write ( highestPowerof2 ( n ) ) ;