Program to print all substrings of a given string | Function to print all substring ; Pick starting point in outer loop and lengths of different strings for a given starting point ; Driver code
function SubString ( str , n ) { for ( var i = 0 ; i < n ; i ++ ) for ( var j = i + 1 ; j <= n ; j ++ ) document . write ( str . substring ( i , j ) + " " ) ; } var str = " " ; SubString ( str , str . length ) ;