Create a sub element from string object in JavaScript

Description

The following code shows how to create a sub element from string object.

Example


<!-- w w w  . j  a va  2s .co m-->
<!DOCTYPE html>
<html>
<body>
<script type="text/javascript">
var myString = new String();
myString = "java2s.com";
document.writeln(myString.sub());
</script>
</body>
</html>

Click to view the demo

The code above generates the following result.

Create a sub element from string object in JavaScript