--- 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/Referencje/Obiekty/String/prototype ---

{{JSRef}}

Podsumowanie

Reprezentuje prototyp obiektów danej klasy. Pozwala na dodawanie własności i metod do wszystkich instancji tej klasy.

{{js_property_attributes(0, 0, 0)}}

Opis

Wszystkie instancje {{jsxref("Global_Objects/String", "String")}} dziedziczą z  String.prototype. Zmiany w prototypie obiektu String są propagowane do wszystkich instancji {{jsxref("Global_Objects/String", "String")}}.

Własności

String.prototype.constructor
Oznacza funkcję, która tworzy prototyp obiektu.
{{jsxref("String.prototype.length")}}
Odzwierciedla długość łańcucha znaków.
N
Używane celem uzyskania dostępu do znaku na pozycji N-tej gdzie  N jest dodatnią liczbą całkowitą między 0 a o jeden mniejszą od {{jsxref("String.length", "length")}}. Własności te są tylko do odczytu.

Metody

Metody niezwiązane z HTML

{{jsxref("String.prototype.charAt()")}}
Zwraca znak o podanym indeksie.
{{jsxref("String.prototype.charCodeAt()")}}
Zwraca liczbę oznaczającą wartość Unicode znaku o podanym indeksie.
{{jsxref("String.prototype.codePointAt()")}} {{experimental_inline}}
Returns a non-negative integer that is the UTF-16 encoded code point value at the given position.
{{jsxref("String.prototype.concat()")}}
Łączy dwa łańcuchy znaków i zwraca nowy łańcuch.
{{jsxref("String.prototype.includes()")}} {{experimental_inline}}
Determines whether one string may be found within another string.
{{jsxref("String.prototype.endsWith()")}} {{experimental_inline}}
Determines whether a string ends with the characters of another string.
{{jsxref("String.prototype.indexOf()")}}
Zwraca indeks pierwszego wystąpienia podanego znaku w obiekcie String lub -1, gdy niczego nie znaleziono.
{{jsxref("String.prototype.lastIndexOf()")}}
Zwraca indeks ostatniego wystąpienia podanego znaku w obiekcie String lub -1, gdy niczego nie znaleziono.
{{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()")}}
Używane do porównania wyrażenia regularnego z łańcuchem znaków.
{{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()")}}
Używane do znalezienia podobieństwa pomiędzy wyrażeniem regularnym a łańcuchem znaków, a następnie do podmiany znalezionego podłańcucha nowym podłańcuchem.
{{jsxref("String.prototype.search()")}}
Uruchamia wyszukiwanie podobieństwa pomiędzy wyrażeniem regularnym a podanym łańcuchem.
{{jsxref("String.prototype.slice()")}}
Wyciąga kawałek łańcucha i zwraca nowy łańcuch.
{{jsxref("String.prototype.split()")}}
Dzieli obiekt {{jsxref("String")}} na tablicę łańcuchów poprzez dzielenie łańcucha na podłańcuchy.
{{jsxref("String.prototype.startsWith()")}} {{experimental_inline}}
Determines whether a string begins with the characters of another string.
{{jsxref("String.prototype.substr()")}}
Zwraca podłańcuch znaków z łańcucha, zaczynający się w podanym miejscu i podanej długości znaków.
{{jsxref("String.prototype.substring()")}}
Zwraca znaki w podłańcuchu pomiędzy dwoma indeksami w łańcuchu.
{{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()")}}
Zwraca wywołujący łańcuch skonwertowany do małych liter.
{{jsxref("String.prototype.toSource()")}} {{non-standard_inline}}
Zwraca literał obiektu reprezentujący podany obiekt; możesz użyć tej wartości do utworzenia nowego obiektu. Przesłania metodę {{jsxref("Object.prototype.toSource()")}}.
{{jsxref("String.prototype.toString()")}}
Zwraca łańcuch reprezentujący podany obiekt. Przesłania metodę {{jsxref("Object.prototype.toString()")}}.
{{jsxref("String.prototype.toUpperCase()")}}
Zwraca wywołujący łańcuch skonwertowany do wielkich liter.
{{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()")}}
Zwraca wartość prymitywną podanego obiektu. Przesłania metodę {{jsxref("Object.prototype.valueOf()")}}.
{{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.

Metody związane z HTML

These methods are of limited use, as they provide only a subset of the available HTML tags and attributes.

{{jsxref("String.prototype.anchor()")}}
{{htmlattrxref("name", "a", "<a name=\"name\">")}} (hypertext target)
{{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