How To Use String Object SubString In JavaScript

In this article I am going to explain about String Object SubString In JavaScript.
  • 1807

Use substring() method in JavaScript

The substring() method is used to extract all string, between two specified indices, and this method returns the new sub string in JavaScript.

The substring() method extracts the all string between "from" and "to", not including "to" itself.

The index will be start 0, like(0,1,2).

All browsers support string object substring() method.

Syntax

string.substring(from, to)

Example

<!DOCTYPE html>

<html>

<body style ="background-color :Red">

 

<script type="text/javascript">

 

    var str = "Welcome dotnetheaven!";

    document.write(str.substring(3) + "<br />");

    document.write(str.substring(3, 9));

 

</script>

 

</body>

</html>

Output1

 op1.jpgop1.jpg

Further Readings

You may also want to read these related articles :here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.