Get your own website Result Size: 625 x 565
x
 
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Strings</h1>
<h2>The substring() Method</h2>
<p>substring() extracts a part of a string:</p>
<p id="demo"></p>
<script>
let text = "Hello world!";
let result = text.substring(1, 4);
document.getElementById("demo").innerHTML = result;
</script>
</body>
</html>