Javascript Data Type How to - Cut a substring from a string to the end








Question

We would like to know how to cut a substring from a string to the end.

Answer


<!DOCTYPE html>
<html>
<head>
</head><!--  www .  ja  v a  2s.c  om-->
<body>
  <script type='text/javascript'>
var strIn  = 'http://localhost/40ATV/dashboard.php?page_id=projeto_lista&lista_tipo=equipe',
    index  = strIn.indexOf('/dashboard.php'),
    strOut = strIn.substr(index);
document.writeln(strOut);

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

The code above is rendered as follows: