Javascript Data Type How to - Replace a string by range








Question

We would like to know how to replace a string by range.

Answer


<!DOCTYPE html>
<html>
<body>
<script type='text/javascript'>
<!-- w  ww .j  av  a2  s  .  c  o  m-->
    var str = "this is a string";
    var result = "that" + str.substring(4);
    document.writeln(result);

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

The code above is rendered as follows: