---
title: String.prototype
slug: conflicting/Web/JavaScript/Reference/Global_Objects/String
tags:
- JavaScript
- Property
- Prototype
- String
translation_of: Web/JavaScript/Reference/Global_Objects/String
translation_of_original: Web/JavaScript/Reference/Global_Objects/String/prototype
original_slug: Web/JavaScript/Reference/Global_Objects/String/prototype
---
{{JSRef("Global_Objects", "String")}}
요약
String.prototype
프라퍼티는 {{jsxref("Global_Objects/String", "String")}} 프로토타입 오브젝트를 표현하고 있습니다.
{{js_property_attributes(0, 0, 0)}}
설명
모든 {{jsxref("Global_Objects/String", "String")}} 인스턴스들은 String.prototype
를 상속합니다. String
프라퍼티 오브젝트를 변경하면, 그 변경은 모든 {{jsxref("Global_Objects/String", "String")}} 인스턴스들에 영향을 주게 됩니다.
Properties
String.prototype.constructor
- 오브젝트의 프로토타입을 생성하는 함수를 명세합니다.
- {{jsxref("String.prototype.length")}}
- 문자열의 길이를 반영합니다.
N
- N번째 위치에 있는 문자에 접근하기 위해 사용합니다. N 은 0과 {{jsxref("String.length", "length")}}보다 작은 값 사이에 있는 양의 정수입니다. 이 퍼라퍼티들은 읽기 전용(read-only) 속성을 가지고 있습니다.
메서드
- {{jsxref("String.prototype.charAt()")}}
- 문자열 내 특정 위치(index)에 있는 문자를 반환합니다.
- {{jsxref("String.prototype.charCodeAt()")}}
- 문자열 내 주어진 위치(index)에 있는 문자의 유니코드 값을 반환합니다.
- {{jsxref("String.prototype.codePointAt()")}} {{experimental_inline}}
- 주어진 위치에 있는 UTF-16으로 인코딩된 코드 포인터값인 음수가 아닌 정수값을 반환합니다.
- {{jsxref("String.prototype.concat()")}}
- 두 문자열의 문자를 합쳐서 새로운 문자열로 만든 다음, 그 새로운 문자열을 반환합니다.
- {{jsxref("String.prototype.includes()")}} {{experimental_inline}}
- 문자열 내에 찾고자 하는 문자열이 있는지를 확인합니다.
- {{jsxref("String.prototype.endsWith()")}} {{experimental_inline}}
- 문자열에서 특정 문자열로 끝나는지를 확인할 수 있습니다.
- {{jsxref("String.prototype.indexOf()")}}
- {{jsxref("Global_Objects/String", "String")}} 오브젝트에 있는 특정 값이 일치하는 첫 번째 인덱스 값을 반환하며, 일치하는 값이 없을 경우에는 -1을 반환합니다.
- {{jsxref("String.prototype.lastIndexOf()")}}
String
오브젝트에서 fromIndex
로부터 반대방향으로 찾기 시작하여 특정 값이 일치하는 마지막 인덱스를 반환합니다. 문자열에서 일치하는 특정 값이 없으면 -1
을 리턴합니다.
- {{jsxref("String.prototype.localeCompare()")}}
- Returns a number indicating whether a reference string comes before or after or is the same as the given string in sort order.
- {{jsxref("String.prototype.match()")}}
- Used to match a regular expression against a string.
- {{jsxref("String.prototype.normalize()")}} {{experimental_inline}}
- Returns the Unicode Normalization Form of the calling string value.
{{jsxref("String.prototype.quote()")}} {{obsolete_inline}}
Wraps the string in double quotes (""
").
- {{jsxref("String.prototype.repeat()")}} {{experimental_inline}}
- Returns a string consisting of the elements of the object repeated the given times.
- {{jsxref("String.prototype.replace()")}}
- Used to find a match between a regular expression and a string, and to replace the matched substring with a new substring.
- {{jsxref("String.prototype.search()")}}
- Executes the search for a match between a regular expression and a specified string.
- {{jsxref("String.prototype.slice()")}}
- Extracts a section of a string and returns a new string.
- {{jsxref("String.prototype.split()")}}
- Splits a {{jsxref("Global_Objects/String", "String")}} object into an array of strings by separating the string into substrings.
- {{jsxref("String.prototype.startsWith()")}} {{experimental_inline}}
- Determines whether a string begins with the characters of another string.
- {{jsxref("String.prototype.substr()")}}
- Returns the characters in a string beginning at the specified location through the specified number of characters.
- {{jsxref("String.prototype.substring()")}}
- Returns the characters in a string between two indexes into the string.
- {{jsxref("String.prototype.toLocaleLowerCase()")}}
- The characters within a string are converted to lower case while respecting the current locale. For most languages, this will return the same as {{jsxref("String.prototype.toLowerCase()", "toLowerCase()")}}.
- {{jsxref("String.prototype.toLocaleUpperCase()")}}
- The characters within a string are converted to upper case while respecting the current locale. For most languages, this will return the same as {{jsxref("String.prototype.toUpperCase()", "toUpperCase()")}}.
- {{jsxref("String.prototype.toLowerCase()")}}
- Returns the calling string value converted to lower case.
- {{jsxref("String.prototype.toSource()")}} {{non-standard_inline}}
- Returns an object literal representing the specified object; you can use this value to create a new object. Overrides the {{jsxref("Object.prototype.toSource()")}} method.
- {{jsxref("String.prototype.toString()")}}
- Returns a string representing the specified object. Overrides the {{jsxref("Object.prototype.toString()")}} method.
- {{jsxref("String.prototype.toUpperCase()")}}
- Returns the calling string value converted to uppercase.
- {{jsxref("String.prototype.trim()")}}
- Trims whitespace from the beginning and end of the string. Part of the ECMAScript 5 standard.
- {{jsxref("String.prototype.trimLeft()")}} {{non-standard_inline}}
- Trims whitespace from the left side of the string.
- {{jsxref("String.prototype.trimRight()")}} {{non-standard_inline}}
- Trims whitespace from the right side of the string.
- {{jsxref("String.prototype.valueOf()")}}
- Returns the primitive value of the specified object. Overrides the {{jsxref("Object.prototype.valueOf()")}} method.
- {{jsxref("String.prototype.@@iterator()", "String.prototype[@@iterator]()")}} {{experimental_inline}}
- Returns a new
Iterator
object that iterates over the code points of a String value, returning each code point as a String value.
HTML wrapper methods
These methods are of limited use, as they provide only a subset of the available HTML tags and attributes.
- {{jsxref("String.prototype.big()")}} {{deprecated_inline}}
- {{HTMLElement("big")}}
- {{jsxref("String.prototype.blink()")}} {{deprecated_inline}}
- {{HTMLElement("blink")}}
- {{jsxref("String.prototype.bold()")}} {{deprecated_inline}}
- {{HTMLElement("b")}}
- {{jsxref("String.prototype.fixed()")}} {{deprecated_inline}}
- {{HTMLElement("tt")}}
- {{jsxref("String.prototype.fontcolor()")}} {{deprecated_inline}}
- {{htmlattrxref("color", "font", "<font color=\"color\">")}}
- {{jsxref("String.prototype.fontsize()")}} {{deprecated_inline}}
- {{htmlattrxref("size", "font", "<font size=\"size\">")}}
- {{jsxref("String.prototype.italics()")}} {{deprecated_inline}}
- {{HTMLElement("i")}}
- {{jsxref("String.prototype.link()")}}
- {{htmlattrxref("href", "a", "<a href=\"rul\">")}} (link to URL)
- {{jsxref("String.prototype.small()")}} {{deprecated_inline}}
- {{HTMLElement("small")}}
- {{jsxref("String.prototype.strike()")}} {{deprecated_inline}}
- {{HTMLElement("strike")}}
- {{jsxref("String.prototype.sub()")}} {{deprecated_inline}}
- {{HTMLElement("sub")}}
- {{jsxref("String.prototype.sup()")}} {{deprecated_inline}}
- {{HTMLElement("sup")}}
Specifications
Specification |
Status |
Comment |
ECMAScript 1st Edition. |
Standard |
Initial definition. |
{{SpecName('ES5.1', '#sec-15.5.3.1', 'String.prototype')}} |
{{Spec2('ES5.1')}} |
|
{{SpecName('ES6', '#sec-string.prototype', 'String.prototype')}} |
{{Spec2('ES6')}} |
|
Browser compatibility
{{CompatibilityTable}}
Feature |
Chrome |
Firefox (Gecko) |
Internet Explorer |
Opera |
Safari |
Basic support |
{{CompatVersionUnknown}} |
{{CompatVersionUnknown}} |
{{CompatVersionUnknown}} |
{{CompatVersionUnknown}} |
{{CompatVersionUnknown}} |
Feature |
Android |
Chrome for Android |
Firefox Mobile (Gecko) |
IE Mobile |
Opera Mobile |
Safari Mobile |
Basic support |
{{CompatVersionUnknown}} |
{{CompatVersionUnknown}} |
{{CompatVersionUnknown}} |
{{CompatVersionUnknown}} |
{{CompatVersionUnknown}} |
{{CompatVersionUnknown}} |
See also
- {{jsxref("Global_Objects/String", "String")}}
- {{jsxref("Function.prototype")}}