본문 바로가기

JS/TypeScript

타입스크립트 튜토리얼 String

문자열 객체는 문자들의 나열로 작업할 수 있다. 문자열 기본 데이터 형식을 여러 가지 도우미 메서드로 래핑한다.

문법

var var_name = new String(string);

String 객체에서 사용할 수 있는 메서드 목록

S.No.Property & Description
1.Constructor

Returns a reference to the String function that created the object.

2.Length

Returns the length of the string.

3.Prototype

The prototype property allows you to add properties and methods to an object.

문자열 메서드

S.No.Method & Description
1.charAt()

Returns the character at the specified index.

2.charCodeAt()

Returns a number indicating the Unicode value of the character at the given index.

3.concat()

Combines the text of two strings and returns a new string.

4.indexOf()

Returns the index within the calling String object of the first occurrence of the specified value, or -1 if not found.

5.lastIndexOf()

Returns the index within the calling String object of the last occurrence of the specified value, or -1 if not found.

6.localeCompare()

Returns a number indicating whether a reference string comes before or after or is the same as the given string in sort order.

7.

match()

Used to match a regular expression against a string.

8.replace()

Used to find a match between a regular expression and a string, and to replace the matched substring with a new substring.

9.search()

Executes the search for a match between a regular expression and a specified string.

10.slice()

Extracts a section of a string and returns a new string.

11.split()

Splits a String object into an array of strings by separating the string into substrings.

12.substr()

Returns the characters in a string beginning at the specified location through the specified number of characters.

13.substring()

Returns the characters in a string between two indexes into the string.

14.toLocaleLowerCase()

The characters within a string are converted to lower case while respecting the current locale.

15.toLocaleUpperCase()

The characters within a string are converted to upper case while respecting the current locale.

16.toLowerCase()

Returns the calling string value converted to lower case.

17.toString()

Returns a string representing the specified object.

18.toUpperCase()

Returns the calling string value converted to uppercase.

19.valueOf()

Returns the primitive value of the specified object.

https://www.tutorialspoint.com/typescript/typescript_strings.htm

'JS > TypeScript' 카테고리의 다른 글

타입스크립트 튜토리얼 split  (0) 2018.12.21
타입스크립트 substr() substring()  (0) 2018.12.21
타입스크립트 튜토리얼 Number  (0) 2018.12.21
타입스크립트 함수  (0) 2018.12.15
타입스크립트 튜토리얼 루프  (0) 2018.12.15