// the substring method returns a string out of another stringconst str ='Mozilla';console.log(str.substring(1,3));// expected output: "oz"console.log(str.substring(2));// expected output: "zilla"
//substring() is similar to slice().//The difference is that start and end values less than 0 are treated as 0 in substring()let str ="Apple, Banana, Kiwi";let part = str.substring(7,13);// >> Banana//if you find this answer is useful ,//upvote ⇑⇑ , so can the others benefit also . @mohammad alshraideh ( ͡~ ͜ʖ ͡°)
const str ="Learning to code";// substring between index 2 and index 5console.log(str.substring(2,5));// substring between index 0 and index 4console.log(str.substring(0,4));// using substring() method without endIndexconsole.log(str.substring(2));console.log(str.substring(5));
const str ="Learning to code";// start index is 1, length is 4console.log(str.substr(1,10));// start index is 3, length is 2console.log(str.substr(3,2));// length not given// string extract to end of the stringconsole.log(str.substr(5));
//substr() is similar to slice().//The difference is that the second parameter specifies the length of the extracted partlet str ="Apple, Banana, Kiwi";let part = str.substr(7,6);// >> Banana//if you find this answer is useful ,//upvote ⇑⇑ , so can the others benefit also . @mohammad alshraideh ( ͡~ ͜ʖ ͡°)
var string ="WelcomeToSofthunt.netTutorialWebsite";
one = string.substring(0,7)
two = string.substring(7,9)
three = string.substring(9,21)
four = string.substring(21,29)
five = string.substring(29,36)
six = string.substring(0)document.write(one);document.write(two);document.write(three);document.write(four);document.write(five);document.write(six);