//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 ( ͡~ ͜ʖ ͡°)
let str = 'JavaScript Substring';
let substring = str.substring(0,10);
console.log(substring);
Code language: JavaScript (javascript)
//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 ( ͡~ ͜ʖ ͡°)
s ="abcdefghijklmnopqrstuvwxyz"
print(s[0:len(s)])
#prints the entire string from 0 to len(s)-1
s = ' hello '
s = s[3:8] # no crash if s[3:20]
# 'hello'