Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 536973 of String.prototype

  • URL revize: Web/JavaScript/Reference/Global_Objects/String/prototype
  • Název revize: String.prototype
  • ID revize: 536973
  • Vytvořeno:
  • Autor: angel333
  • Aktuální revize? Ano
  • Komentář

Obsah revize

{{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}}
Vrací nezáporné celé číslo, které představuje hodnotu znaku v UTF-16 (code point) na dané pozici.
{{jsxref("String.prototype.concat()")}}
Spojí texty dvou řetězců a vrací nový řetězec.
{{jsxref("String.prototype.contains()")}} {{experimental_inline}}
Zjišťuje, zda je řetězec součástí jiného řetězce.
{{jsxref("String.prototype.endsWith()")}} {{experimental_inline}}
Zjišťuje, jestli řetězec končí znaky jiného řetězce.
{{jsxref("String.prototype.indexOf()")}}
Vrací index prvního výskytu dané hodnty v objektu String, který metodu volá. Pokud nic není nalezeno, vrací -1.
{{jsxref("String.prototype.lastIndexOf()")}}
Vrací index posledního výskytu dané hodnty v objektu String, který metodu volá. Pokud nic není nalezeno, vrací -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.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")}}

Zdroj revize

<p>{{JSRef("Global_Objects", "String")}}</p>
<h2 id="Summary" name="Summary">Souhrn</h2>
<p>Vlastnost&nbsp;<code><strong>String.prototype</strong></code> reprezentuje prototypový objekt {{jsxref("Global_Objects/String", "String")}}.</p>
<div>
 {{js_property_attributes(0,0,0)}}</div>
<h2 id="Description" name="Description">Popis</h2>
<p>Všechny instance&nbsp;<code>String</code>&nbsp;dědí ze&nbsp;<code>String.prototype</code>. Změny v prototypovém objektu&nbsp;<code>String</code> se přenášejí do všech instancí&nbsp;<code>String</code>.</p>
<h2 id="Properties" name="Properties">Vlastnosti</h2>
<dl>
 <dt>
  <code>String.prototype.constructor</code></dt>
 <dd>
  Určuje funkci, která vytváří prototyp objektu.</dd>
 <dt>
  {{jsxref("String.prototype.length")}}</dt>
 <dd>
  Reprezentuje délku řetězce.</dd>
 <dt>
  <em>N</em></dt>
 <dd>
  Používá se pro přístup ke znaku Nté pozici, kde&nbsp;<em>N</em> je kladné celé číslo od 0 do hodnoty o 1 menší než {{jsxref("String.length", "length")}}. Tyto vlastnosti jsou pouze pro čtení.</dd>
</dl>
<div>
 {{ jsOverrides("Object", "properties", "constructor", "length") }}</div>
<h2 id="Methods" name="Methods">Metody</h2>
<h3 id="Methods_unrelated_to_HTML" name="Methods_unrelated_to_HTML">Metody nesouvisející s HTML</h3>
<dl>
 <dt>
  {{jsxref("String.prototype.charAt()")}}</dt>
 <dd>
  Vrací znak na určeném indexu.</dd>
 <dt>
  {{jsxref("String.prototype.charCodeAt()")}}</dt>
 <dd>
  Vrací číslo označující hodnotu Unicode pro znak na daném indexu.</dd>
 <dt>
  {{jsxref("String.prototype.codePointAt()")}} {{experimental_inline}}</dt>
 <dd>
  Vrací nezáporné celé číslo, které představuje hodnotu znaku v UTF-16 (code point) na dané pozici.</dd>
 <dt>
  {{jsxref("String.prototype.concat()")}}</dt>
 <dd>
  Spojí texty dvou řetězců a vrací nový řetězec.</dd>
 <dt>
  {{jsxref("String.prototype.contains()")}} {{experimental_inline}}</dt>
 <dd>
  Zjišťuje, zda je řetězec součástí jiného řetězce.</dd>
 <dt>
  {{jsxref("String.prototype.endsWith()")}} {{experimental_inline}}</dt>
 <dd>
  Zjišťuje, jestli řetězec končí znaky jiného řetězce.</dd>
 <dt>
  {{jsxref("String.prototype.indexOf()")}}</dt>
 <dd>
  Vrací index prvního výskytu dané hodnty v objektu String, který metodu volá. Pokud nic není nalezeno, vrací -1.</dd>
 <dt>
  {{jsxref("String.prototype.lastIndexOf()")}}</dt>
 <dd>
  Vrací index posledního výskytu dané hodnty v objektu String, který metodu volá. Pokud nic není nalezeno, vrací -1.</dd>
 <dt>
  {{jsxref("String.prototype.localeCompare()")}}</dt>
 <dd>
  Returns a number indicating whether a reference string comes before or after or is the same as the given string in sort order.</dd>
 <dt>
  {{jsxref("String.prototype.match()")}}</dt>
 <dd>
  Used to match a regular expression against a string.</dd>
 <dt>
  {{jsxref("String.prototype.quote()")}} {{ Non-standard_inline() }}</dt>
 <dd>
  Wraps the string in double quotes ("<code>"</code>").</dd>
 <dt>
  {{jsxref("String.prototype.repeat()")}} {{experimental_inline}}</dt>
 <dd>
  Returns a string consisting of the elements of the object repeated the given times.</dd>
 <dt>
  {{jsxref("String.prototype.replace()")}}</dt>
 <dd>
  Used to find a match between a regular expression and a string, and to replace the matched substring with a new substring.</dd>
 <dt>
  {{jsxref("String.prototype.search()")}}</dt>
 <dd>
  Executes the search for a match between a regular expression and a specified string.</dd>
 <dt>
  {{jsxref("String.prototype.slice()")}}</dt>
 <dd>
  Extracts a section of a string and returns a new string.</dd>
 <dt>
  {{jsxref("String.prototype.split()")}}</dt>
 <dd>
  Splits a String object into an array of strings by separating the string into substrings.</dd>
 <dt>
  {{jsxref("String.prototype.startsWith()")}} {{experimental_inline}}</dt>
 <dd>
  Determines whether a string begins with the characters of another string.</dd>
 <dt>
  {{jsxref("String.prototype.substr()")}}</dt>
 <dd>
  Returns the characters in a string beginning at the specified location through the specified number of characters.</dd>
 <dt>
  {{jsxref("String.prototype.substring()")}}</dt>
 <dd>
  Returns the characters in a string between two indexes into the string.</dd>
 <dt>
  {{jsxref("String.prototype.toLocaleLowerCase()")}}</dt>
 <dd>
  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")}}.</dd>
 <dt>
  {{jsxref("String.prototype.toLocaleUpperCase()")}}</dt>
 <dd>
  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")}}.</dd>
 <dt>
  {{jsxref("String.prototype.toLowerCase()")}}</dt>
 <dd>
  Returns the calling string value converted to lower case.</dd>
 <dt>
  {{jsxref("String.prototype.toSource()")}} {{ Non-standard_inline() }}</dt>
 <dd>
  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.</dd>
 <dt>
  {{jsxref("String.prototype.toString()")}}</dt>
 <dd>
  Returns a string representing the specified object. Overrides the {{jsxref("Object.prototype.toString")}} method.</dd>
 <dt>
  {{jsxref("String.prototype.toUpperCase()")}}</dt>
 <dd>
  Returns the calling string value converted to uppercase.</dd>
 <dt>
  {{jsxref("String.prototype.trim()")}}</dt>
 <dd>
  Trims whitespace from the beginning and end of the string. Part of the ECMAScript 5 standard.</dd>
 <dt>
  {{jsxref("String.prototype.trimLeft()")}} {{ Non-standard_inline() }}</dt>
 <dd>
  Trims whitespace from the left side of the string.</dd>
 <dt>
  {{jsxref("String.prototype.trimRight()")}} {{ Non-standard_inline() }}</dt>
 <dd>
  Trims whitespace from the right side of the string.</dd>
 <dt>
  {{jsxref("String.prototype.valueOf()")}}</dt>
 <dd>
  Returns the primitive value of the specified object. Overrides the {{jsxref("Object.prototype.valueOf")}} method.</dd>
</dl>
<h3 id="HTML_wrapper_methods" name="HTML_wrapper_methods">Metody pro obalení HTML</h3>
<p>Tyto metody mají omezené použití, protože obsahují pouze část dostupných HTML tagů a atributů.</p>
<dl>
 <dt>
  {{jsxref("String.prototype.anchor()")}}</dt>
 <dd>
  <code><a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-name">&lt;a name="name"&gt;</a></code> (hypertext target)</dd>
 <dt>
  {{jsxref("String.prototype.big()")}}</dt>
 <dd>
  {{HTMLElement("big")}}</dd>
 <dt>
  {{jsxref("String.prototype.blink()")}}</dt>
 <dd>
  {{HTMLElement("blink")}}</dd>
 <dt>
  {{jsxref("String.prototype.bold()")}}</dt>
 <dd>
  {{HTMLElement("b")}}</dd>
 <dt>
  {{jsxref("String.prototype.fixed()")}}</dt>
 <dd>
  {{HTMLElement("tt")}}</dd>
 <dt>
  {{jsxref("String.prototype.fontcolor()")}}</dt>
 <dd>
  <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/font#attr-color"><code>&lt;font color="<em>color</em>"&gt;</code></a></dd>
 <dt>
  {{jsxref("String.prototype.fontsize()")}}</dt>
 <dd>
  <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/font#attr-size"><code>&lt;font size="<em>size</em>"&gt;</code></a></dd>
 <dt>
  {{jsxref("String.prototype.italics()")}}</dt>
 <dd>
  {{HTMLElement("i")}}</dd>
 <dt>
  {{jsxref("String.prototype.link()")}}</dt>
 <dd>
  <a class="external" href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-href"><code>&lt;a href="<em>url</em>"&gt;</code></a> (link to URL)</dd>
 <dt>
  {{jsxref("String.prototype.small()")}}</dt>
 <dd>
  {{HTMLElement("small")}}</dd>
 <dt>
  {{jsxref("String.prototype.strike()")}}</dt>
 <dd>
  {{HTMLElement("strike")}}</dd>
 <dt>
  {{jsxref("String.prototype.sub()")}}</dt>
 <dd>
  {{HTMLElement("sub")}}</dd>
 <dt>
  {{jsxref("String.prototype.sup()")}}</dt>
 <dd>
  {{HTMLElement("sup")}}</dd>
</dl>
<div>
 {{ 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") }}</div>
<h2 id="Specifikace">Specifikace</h2>
<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Specifikace</th>
   <th scope="col">Stav</th>
   <th scope="col">Komentář</th>
  </tr>
  <tr>
   <td>ECMAScript 1. edice.</td>
   <td>Standardní</td>
   <td>První definice.</td>
  </tr>
  <tr>
   <td>{{SpecName('ES5.1', '#sec-15.5.3.1', 'String.prototype')}}</td>
   <td>{{Spec2('ES5.1')}}</td>
   <td>&nbsp;</td>
  </tr>
  <tr>
   <td>{{SpecName('ES6', '#sec-string.prototype', 'String.prototype')}}</td>
   <td>{{Spec2('ES6')}}</td>
   <td>&nbsp;</td>
  </tr>
 </tbody>
</table>
<h2 id="Kompatibilita_v_prohl.C3.AD.C5.BEe.C4.8D.C3.ADch">Kompatibilita v prohlížečích</h2>
<p>{{ CompatibilityTable() }}</p>
<div id="compat-desktop">
 <table class="compat-table">
  <tbody>
   <tr>
    <th>Vlastnost</th>
    <th>Chrome</th>
    <th>Firefox (Gecko)</th>
    <th>Internet Explorer</th>
    <th>Opera</th>
    <th>Safari</th>
   </tr>
   <tr>
    <td>Základní podpora</td>
    <td>{{ CompatVersionUnknown() }}</td>
    <td>{{ CompatVersionUnknown() }}</td>
    <td>{{ CompatVersionUnknown() }}</td>
    <td>{{ CompatVersionUnknown() }}</td>
    <td>{{ CompatVersionUnknown() }}</td>
   </tr>
  </tbody>
 </table>
</div>
<div id="compat-mobile">
 <table class="compat-table">
  <tbody>
   <tr>
    <th>Vlastnost</th>
    <th>Android</th>
    <th>Chrome pro Android</th>
    <th>Firefox Mobile (Gecko)</th>
    <th>IE Mobile</th>
    <th>Opera Mobile</th>
    <th>Safari Mobile</th>
   </tr>
   <tr>
    <td>Základní podpora</td>
    <td>{{ CompatVersionUnknown() }}</td>
    <td>{{ CompatVersionUnknown() }}</td>
    <td>{{ CompatVersionUnknown() }}</td>
    <td>{{ CompatVersionUnknown() }}</td>
    <td>{{ CompatVersionUnknown() }}</td>
    <td>{{ CompatVersionUnknown() }}</td>
   </tr>
  </tbody>
 </table>
</div>
<h2 id="See_also" name="See_also">Související</h2>
<ul>
 <li>{{jsxref("Global_Objects/String", "String")}}</li>
 <li>{{jsxref("Function.prototype")}}</li>
</ul>
Návrat k této revizi