//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 5
console.log(str.substring(2, 5));
// substring between index 0 and index 4
console.log(str.substring(0, 4));
// using substring() method without endIndex
console.log(str.substring(2));
console.log(str.substring(5));
const str = "Learning to code";
// start index is 1, length is 4
console.log(str.substr(1, 10));
// start index is 3, length is 2
console.log(str.substr(3, 2));
// length not given
// string extract to end of the string
console.log(str.substr(5));
//substr() is similar to slice().
//The difference is that the second parameter specifies the length of the extracted part
let 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.substr(0, 7)
two = string.substr(7, 2)
three = string.substr(9,12)
four = string.substr(21, 8)
five = string.substr(29,36)
six = string.substr(0)
document.write(one);
document.write(two);
document.write(three);
document.write(four);
document.write(five);
document.write(six);
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);