String.prototype.split()
String.prototype.split() is a JavaScript method in the String category. Splits a string into an array of substrings. The syntax is str.split(separator, limit). It returns An array of strings. A typical example: "a-b-c".split("-") // ["a", "b", "c"]. Another practical use — Parse CSV data: const csv = 'Alice,25,NYC' const parts = csv.split(',') console.log(parts) // ['Alice', '25', 'NYC'] Its time complexity is O(n), which matters when it runs over large inputs. The TypeScript signature is (separator: string | RegExp, limit?: number): string[]. Common pitfall — Empty string returns array of characters. "".split("") returns [] not [""]. "abc".split("") returns ["a","b","c"]. A close sibling is String.prototype.charAt(), which returns the character at the specified index. A close sibling is String.prototype.charCodeAt(), which returns the Unicode value of the character at the specified index. A close sibling is String.prototype.concat(), which concatenates strings together. A close sibling is String.prototype.includes(), which checks if a string contains a specified substring.