Category
The string to trim
The character to remove from the start of string
A string with the leading start
characters removed
trimStart('aabbcc', 'a'); // 'bbcc'
(trimEnd:1) to do the same thing but trim from the end of a string
String
Category
Removes the leading start
characters from an array.
Time complexity: O(n)
Space complexity: O(n)
A shallow-copied array with the leading start
characters removed
trimStart(['a', 'a', 'b', 'b', 'c', 'c'], 'a'); // ['b', 'b', 'c', 'c']
(trimEnd:2) to do the same thing but trim from the end of an array
Array
Removes the leading
start
characters from a string.Time complexity: O(n)
Space complexity: O(n)