{{JSRef("Global_Objects", "String")}}
Souhrn
Vlastnost String.prototype
reprezentuje prototypový objekt {{jsxref("Global_Objects/String", "String")}}.
{{js_property_attributes(0,0,0)}}
Popis
Všechny instance String
dědí ze String.prototype
. Změny v prototypovém objektu String
se přenášejí do všech instancí String
.
Vlastnosti
-
String.prototype.constructor
- Určuje funkci, která vytváří prototyp objektu.
- {{jsxref("String.prototype.length")}}
- Reprezentuje délku řetězce.
- N
- Používá se pro přístup ke znaku Nté pozici, kde N je kladné celé číslo od 0 do hodnoty o 1 menší než {{jsxref("String.length", "length")}}. Tyto vlastnosti jsou pouze pro čtení.
{{ jsOverrides("Object", "properties", "constructor", "length") }}
Metody
Metody nesouvisející s HTML
- {{jsxref("String.prototype.charAt()")}}
- Vrací znak na určeném indexu.
- {{jsxref("String.prototype.charCodeAt()")}}
- Vrací číslo označující hodnotu Unicode pro znak na daném indexu.
- {{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()")}}
- Combines the text of two strings and returns a new string.
- {{jsxref("String.prototype.contains()")}} {{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()")}}
- Returns the index within the calling String object of the first occurrence of the specified value, or -1 if not found.
- {{jsxref("String.prototype.lastIndexOf()")}}
- Returns the index within the calling String object of the last occurrence of the specified value, or -1 if not found.
- {{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.quote()")}} {{ Non-standard_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 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.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.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.
Metody pro obalení HTML
Tyto metody mají omezené použití, protože obsahují pouze část dostupných HTML tagů a atributů.
- {{jsxref("String.prototype.anchor()")}}
-
<a name="name">
(hypertext target) - {{jsxref("String.prototype.big()")}}
- {{HTMLElement("big")}}
- {{jsxref("String.prototype.blink()")}}
- {{HTMLElement("blink")}}
- {{jsxref("String.prototype.bold()")}}
- {{HTMLElement("b")}}
- {{jsxref("String.prototype.fixed()")}}
- {{HTMLElement("tt")}}
- {{jsxref("String.prototype.fontcolor()")}}
-
<font color="color">
- {{jsxref("String.prototype.fontsize()")}}
-
<font size="size">
- {{jsxref("String.prototype.italics()")}}
- {{HTMLElement("i")}}
- {{jsxref("String.prototype.link()")}}
-
<a href="url">
(link to URL) - {{jsxref("String.prototype.small()")}}
- {{HTMLElement("small")}}
- {{jsxref("String.prototype.strike()")}}
- {{HTMLElement("strike")}}
- {{jsxref("String.prototype.sub()")}}
- {{HTMLElement("sub")}}
- {{jsxref("String.prototype.sup()")}}
- {{HTMLElement("sup")}}
{{ jsOverrides("Object", "methods", "charAt", "charCodeAt", "concat", "indexOf", "lastIndexOf", "localeCompare", "match", "quote", "replace", "search", "slice", "split", "substr", "substring", "toLocaleLowerCase", "toLocaleUpperCase", "toLowerCase", "toSource", "toString", "toUpperCase", "trim", "trimLeft", "trimRight", "valueOf", "anchor", "big", "blink", "bold", "fixed", "fontcolor", "fontsize", "italics", "link", "small", "strike", "sub", "sup") }}
Specifikace
Specifikace | Stav | Komentář |
---|---|---|
ECMAScript 1. edice. | Standardní | První definice. |
{{SpecName('ES5.1', '#sec-15.5.3.1', 'String.prototype')}} | {{Spec2('ES5.1')}} | |
{{SpecName('ES6', '#sec-string.prototype', 'String.prototype')}} | {{Spec2('ES6')}} |
Kompatibilita v prohlížečích
{{ CompatibilityTable() }}
Vlastnost | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Základní podpora | {{ CompatVersionUnknown() }} | {{ CompatVersionUnknown() }} | {{ CompatVersionUnknown() }} | {{ CompatVersionUnknown() }} | {{ CompatVersionUnknown() }} |
Vlastnost | Android | Chrome pro Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Základní podpora | {{ CompatVersionUnknown() }} | {{ CompatVersionUnknown() }} | {{ CompatVersionUnknown() }} | {{ CompatVersionUnknown() }} | {{ CompatVersionUnknown() }} | {{ CompatVersionUnknown() }} |
Související
- {{jsxref("Global_Objects/String", "String")}}
- {{jsxref("Function.prototype")}}