includes(str) kiểm tra có chứa substring không (thay indexOf !== -1). startsWith(str) / endsWith(str) kiểm tra đầu/cuối chuỗi. padStart(len, char) / padEnd(len, char) thêm ký tự vào đầu/cuối cho đủ độ dài — ví dụ '5'.padStart(3, '0') cho ra '005', hữu ích để format số thứ tự. trimStart() / trimEnd() xóa whitespace một phía. replaceAll(old, new) thay thế tất cả occurrences, khác replace() chỉ thay lần đầu.
Những methods này giúp code ngắn và dễ đọc hơn nhiều so với regex.
includes(str) checks if a string contains a substring (replaces indexOf !== -1). startsWith(str) / endsWith(str) checks the beginning/end of a string. padStart(len, char) / padEnd(len, char) pads the start/end to a specified length — e.g., '5'.padStart(3, '0') gives '005', useful for formatting ordinal numbers. trimStart() / trimEnd() removes whitespace from one side. replaceAll(old, new) replaces all occurrences, unlike replace() which only replaces the first.
These methods make code much shorter and more readable than regular expressions.