VOOZH about

URL: https://www.geeksforgeeks.org/typescript/typescript-string-slice-method-with-example/

⇱ TypeScript String slice() - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

TypeScript String slice()

Last Updated : 15 Oct, 2024

The slice() is an inbuilt function used to extract a section of a string and return a new string. 

Syntax:

string.slice( beginslice [, endSlice] )

Parameters:

This method accepts two parameters as mentioned above and described below: 

  • beginSlice: This parameter is the zero-based index at which to begin extraction.
  • endSlice: This parameter is the zero-based index at which to end extraction.

Return Value:

This method returns the index of the regular expression inside the string. Otherwise, it returns -1. 

Example 1:

Output:

Geeksforgeeks

Example 2:

Output:

Best Platform
Comment
Article Tags:
Article Tags:

Explore