Slice Method

 let str="FightClub";

// here '5' is the starting index and ending index is assumed to be the last index of the string
console.log(str.slice(5));

// slice(1,5) -Here 1- starting index  5-ending index
console.log(str.slice(1,5));
console.log(str.slice(5,9));

// slice(-1) =slice(length-1) and this length-1 is considered as the starting index similar to the 1st one
console.log(str.slice(-1));
console.log(str.slice(-5));

Comments

Popular posts from this blog

Callback Hell

TODO list with DOM

Refactoring callback hell code