get indexes for splitted string - Javascript String

Javascript examples for String:indexOf

Description

get indexes for splitted string

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
   </head> 
   <body> 
      <script type="text/javascript">
var str = "The quick brown fox jumps over the lazy dog.";
var arr = str.split(' ');
for( var i = 0, len = arr.length; i < len; i++ ) {
    arr[i] = str.indexOf( arr[i] );
}
document.write( arr );//from w  w w  .  j a v  a  2s  .  c om

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

Related Tutorials