Wednesday, June 30, 2021

TypeScript - String | Example | Demo

String is another primitive data type that is used to store text data. String values are surrounded by single quotation marks or double quotation marks.
Method Description
charAt() Returns the character at the given index
concat() Returns a combination of the two or more specified strings
indexOf() Returns an index of first occurrence of the specified substring from a string (-1 if not found)
replace() Replaces the matched substring with a new substring
split() Splits the string into substrings and returns an array
toUpperCase() Converts all the characters of the string into upper case
toLowerCase() Converts all the characters of the string into lower case
charCodeAt() Returns a number that is the UTF-16 code unit value at the given index
codePointAt() Returns a nonnegative integer Number that is the code point value of the UTF-16 encoded code point starting at the specified index
includes() Checks whether a string includes another string
endsWith() Checks whether a string ends with another string
LastIndexOf() Returns the index of last occurrence of value in the string
localeCompare() Checks whether a string comes before, after or is the same as the given string
match() Matches a regular expression against the given string
normalize() Returns the Unicode Normalization Form of the given string.
padEnd() Pads the end of the current string with the given string
padStart() Pads the beginning of the current string with given string
repeat() Returns a string consisting of the elements of the object repeated in the given times.
search() Searches for a match between a regular expression and a string
slice() Returns a section of a string
startsWith() Checks whether a string starts with another string
substr() Returns a string beginning at the specified location and of the given characters
substring() Returns a string between the two given indexes
toLocaleLowerCase() Returns a lower case string while respecting current locale
toLocaleUpperCase() Returns an upper case string while respecting current locale
trim() Trims the white space from beginning and end of string
trimLeft() Trims the white space from left side of the string
trimRight() Trims the white space from right side of the string


Demo





No comments:

Post a Comment

How to build an Express and Node.js app with Typescript

  In this tutorial, you will learn how to set up a Node.js and Express project with Typescript and live auto-reloading. Note that this metho...