Sub String in JavaScript

Source code :

var str = "Hello world!";

var result = str.substr(1, 4);

alert (result);

Output :

ello

Algorithm :

  1. Assign a String to a variable
  2. Use the keyword substr() to select the particular length of the variable
  3. Print the result

Output :


                

Comments :