trim() |
Remove leading/trailing spaces |
" hi ".trim() → "hi" |
replace(a, b) |
Replace first occurrence |
"aa".replace("a", "b") → "ba" |
replaceAll(a, b) |
Replace all occurrences |
"aa".replaceAll("a", "b") → "bb" |
includes(s) |
Check if contains |
"hello".includes("ell") → true |
indexOf(s) |
Find index |
"hello".indexOf("l") → 2 |
length |
Get length |
"hello".length → 5 |
toUpperCase() |
Convert to uppercase |
"hi".toUpperCase() → "HI" |
toLowerCase() |
Convert to lowercase |
"HI".toLowerCase() → "hi" |
split(sep) |
Split to array |
"a,b".split(",") → ["a","b"] |
slice(start, end) |
Extract portion |
"hello".slice(0, 2) → "he" |
charAt(i) |
Get character at index |
"hello".charAt(0) → "h" |
startsWith(s) |
Check start |
"hello".startsWith("he") → true |
endsWith(s) |
Check end |
"hello".endsWith("lo") → true |
repeat(n) |
Repeat string |
"hi".repeat(3) → "hihihi" |
padStart(n, c) |
Pad start |
"5".padStart(3, "0") → "005" |
padEnd(n, c) |
Pad end |
"5".padEnd(3, "0") → "500" |