JavaScript – substring function

substring() function in JavaScript take particular characters from string with starting point and ending point.

Let’s take an example

If we have string "This is large string in JavaScript"

We want to get only "this is large string" this can be done by substring function

Start index will be 0 here

End index will be 20 here

var str="This is large string in javascript";

var sstr=str.substring(0,20); // substring(startIndex, endIndex)

Demo

  

Bookmark  

 

One Response to “JavaScript – substring function”

  1. d says:

    Coding is hard. I’m ever so screwed.

Leave a Reply

Security Code:

 

  Random Post