Iterate over string and drop words from the end - Javascript String

Javascript examples for String:split

Description

Iterate over string and drop words from the end

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){/*from   w w w .j  a  v a  2 s . c  om*/
var words = "user.schedule.template.edit".split('.');
while(words.length) {
    document.body.innerHTML += words.join('.') + "<br>";
    words.pop();
}
    }

      </script> 
   </head> 
   <body>  
   </body>
</html>

Related Tutorials