[i]Learn· Numbers and strings
String object
You can call methods directly on a string value:
console.log("hello".toUpperCase()); // HELLO
The following methods are available on String values:
- Query: get the character or character code at a particular string index. Methods include
at(),charAt(),charCodeAt(), andcodePointAt(). - Search: get information about a substring that conforms to a pattern, or test if a particular substring exists. Methods include
indexOf(),lastIndexOf(),startsWith(),endsWith(),includes(),match(),matchAll(), andsearch() - Composition: combine strings into a longer string. Methods include
padStart(),padEnd(),concat(), andrepeat(). - Decomposition: break a string into smaller strings. Methods include
split(),slice(),substring(),substr(),trim(),trimStart(), andtrimEnd(). - Transformation: return a new string based on the current string's content. Methods include
toLowerCase(),toUpperCase(),toLocaleLowerCase(),toLocaleUpperCase(),normalize(), andtoWellFormed().
When working with strings, there are two other objects that provide important functionality for string manipulation: RegExp and Intl. They are introduced in regular expressions and internationalization respectively.
example 1 of 1
[>_]Terminal
Output appears here when you press Run.
$ ▌