Friday, December 12, 2025
HomeLanguagesJavascriptTypeScript | String split() Method

TypeScript | String split() Method

The split() is an inbuilt function in TypeScript which is used to splits a String object into an array of strings by separating the string into sub-strings.

Syntax:

string.split([separator][, limit])

Parameter: This method accepts two parameter as mentioned above and described below: 

  • separator – This parameter is  the character to use for separating the string.
  • limit – This parameter is the Integer specifying a limit on the number of splits to be found.

Return Value: This method returns the new array. 
Below examples illustrate the String split() method in TypeScript.
Example 1: 

JavaScript




<script>
    // Original strings
    var str = "Geeksforneveropen - Best Platform";
 
    // use of String split() Method
    var newarr = str.split(" ");
 
    console.log(newarr);
</script>


Output: 

[ 'Geeksforneveropen', '-', 'Best', 'Platform' ]

Example 2: 

JavaScript




<script>
    // Original strings
    var str = "Geeksforneveropen - Best Platform";
 
    // use of String split() Method
    var newarr = str.split("",14);
 
    console.log(newarr);
</script>


Output: 

[ 'G', 'e', 'e', 'k', 's', 'f', 'o', 'r', 'g', 'e', 'e', 'k', 's', ' ' ]
RELATED ARTICLES

Most Popular

Dominic
32444 POSTS0 COMMENTS
Milvus
105 POSTS0 COMMENTS
Nango Kala
6813 POSTS0 COMMENTS
Nicole Veronica
11951 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12026 POSTS0 COMMENTS
Shaida Kate Naidoo
6945 POSTS0 COMMENTS
Ted Musemwa
7198 POSTS0 COMMENTS
Thapelo Manthata
6891 POSTS0 COMMENTS
Umr Jansen
6881 POSTS0 COMMENTS