delimiter : Optional, the separation character
count : Optional, number of split items
The above method reruns an array with 2 values.
In str.split(" ",2), delimiter is a space (" ") character and limit is 2. So it split with space character and returned 2 first 2 strings.
More Split Examples
The above method returns an array with 3 values, because there is no limit for the array, so it returned all the split characters.
It will return "Javascrip, Spli,() Me,hod", because the split character is "t"
It will return 19, because the substring "method" occur in the 19th position in the str.
It will return 10, because the substring "very" last occur in the 10th position in the str.