Skip to content

Latest commit

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

String Methods Cheat Sheet

conststr='HeLlo';conststringObj=newString('grace');
MethodsCode ExampleResultReturn Type
indexOfstr.indexOf('L')2number
indexOf()'hello'.indexOf('l')2number
indexOf()str.indexOf('L')2number
lastIndexOf()'hello'.lastIndexOf('l')3number
search()str.search(/[a-z]/g)1number
endsWith()str.endsWith('z')FALSEboolean
endsWith()str.endsWith('o', 6)TRUEboolean
includes()str.includes('a')FALSEboolean
startsWith()str.startsWith('H', 1)FALSEboolean
startsWith()str.startsWith('H')TRUEboolean
charAt()str.charAt(1)estring
concat()str.concat(' grace')HeLlo gracestring
padEnd()str.padEnd(10, '!')HeLlo!!!!!string
padStart()str.padStart(10, '!')!!!!!HeLlostring
repeat()str.repeat(3))HeLloHeLloHeLlostring
replace()str.replace('L', 'l')Hellostring
replaceAll()hello'.replaceAll('l', 'z')hezzostring
slice()str.slice(1, 3)eLstring
slice()str.slice(2)Llostring
substring()str.substring(2)Llostring
substring()str.substring(1, 3)eLstring
toLowerCase()str.toLowerCase()hellostring
toUpperCase()str.toUpperCase()HELLOstring
trim()' hello '.trim()'hello'string
trimEnd()' hello '.trimEnd()' hello'string
trimStart()' hello '.trimStart()'hello 'string
valueOf()stringObj.valueOf()gracestring
match()str.match(/[A-Z]/g)["H", "L"]array
split()str.split()["HeLlo"]array
split()str.split('')["H", "e", "L", "l", "o"]array

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors