All JavaScript Strings Methods ( Cheatsheet )

Frontend Developer || UI Developer || JavaScript || React
length: Returns the length of a string. Example:"Hello".lengthreturns5.charAt(index): Returns the character at the specified index in a string. Example:"Hello".charAt(1)returns"e".concat(str1, str2, ...): Combines two or more strings and returns a new string. Example:"Hello".concat(" ", "world!")returns"Hello world!".toUpperCase(): Converts a string to uppercase. Example:"hello".toUpperCase()returns"HELLO".toLowerCase(): Converts a string to lowercase. Example:"HELLO".toLowerCase()returns"hello".trim(): Removes whitespace from both ends of a string. Example:" Hello ".trim()returns"Hello".split(separator, limit): Splits a string into an array of substrings based on a specified separator. Example:"Hello,world".split(",")returns["Hello", "world"].indexOf(searchValue, startIndex): Returns the index of the first occurrence of a specified value in a string. Example:"Hello".indexOf("o")returns4.replace(searchValue, newValue): Replaces a specified value with another value in a string. Example:"Hello".replace("o", "i")returns"Helli".substring(startIndex, endIndex): Returns a substring based on the specified start and end index. Example:"Hello".substring(1, 4)returns"ell".slice(startIndex, endIndex): Returns a portion of a string starting from the specified start index to the specified end index. Example:"Hello".slice(1, 4)returns"ell".startsWith(searchString): Checks if a string starts with the specified search string and returns a boolean value. Example:"Hello".startsWith("H")returnstrue.endsWith(searchString): Checks if a string ends with the specified search string and returns a boolean value. Example:"Hello".endsWith("o")returnstrue.includes(searchString): Checks if a string contains the specified search string and returns a boolean value. Example:"Hello".includes("ell")returnstrue.




