The slice() of a String extracts a section of the string and returns it as a new string without modifying the original string.

    
    const sentence = 'The quick brown fox jumps over the lazy dog.';

    const sentenceSlice = sentence.slice(31);
    console.log(sentenceSlice);
    // "the lazy dog."

    const sentenceSlice1 = sentence.slice(4, 19);
    console.log(sentenceSlice1);
    // "quick brown fox"

    const sentenceSlice2 = sentence.slice(-4);
    console.log(sentenceSlice2);
    // "dog."

    const sentenceSlice3 = sentence.slice(-9, -5);
    console.log(sentenceSlice3);
    // "lazy"