Create a string object and then calls it substring method in JavaScript

Description

The following code shows how to create a string object and then calls it substring method.

Example


<!-- w ww.j av a 2s. c om-->

<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
var s1 = "some text";
var s2 = s1.substring(2);
</script>
</head>
<body>
</body>
</html>

Click to view the demo

The code above generates the following result.

Create a string object and then calls it substring method in JavaScript