1let str = 'Hello';
2
3str = str.slice(1);
4console.log(str);
5
6/*
7 Output: ello
8*/
9
1var oldStr ="Hello";
2var newStr = oldStr.substring(1); //remove first character "ello"
3
1let str = 'Hello';
2
3str = str.substring(1);
4console.log(str);
5
6/*
7 Output: ello
8*/
9
1// this will replace the first occurrence of "www." and return "testwww.com"
2"www.testwww.com".replace("www.", "");
3
4// this will slice the first four characters and return "testwww.com"
5"www.testwww.com".slice(4);
6
7// this will replace the www. only if it is at the beginning
8"www.testwww.com".replace(/^(www\.)/,"");