The above code will display Welcome. We can start the slice from by living last 7 characters of the string by using negative number as p2. Let us remove last 7 characters of the string by using negative number as -7. Here is the code.
The output of the above code will be Welcome to www.plus2 , you can note that the last 7 characters of the main string is removed ( sliced ).
Now let us try to collect userid and domain part of an email address by using slice and indexof function.