From de5c456ebded0e038adbf23db34cc290c8829180 Mon Sep 17 00:00:00 2001 From: Florian Merz Date: Thu, 11 Feb 2021 14:49:24 +0100 Subject: unslug pl: move --- .../global_objects/string/anchor/index.html | 56 ++++++ .../reference/global_objects/string/big/index.html | 43 +++++ .../global_objects/string/blink/index.html | 50 ++++++ .../global_objects/string/bold/index.html | 45 +++++ .../global_objects/string/charat/index.html | 68 ++++++++ .../global_objects/string/charcodeat/index.html | 42 +++++ .../global_objects/string/concat/index.html | 44 +++++ .../global_objects/string/fontcolor/index.html | 50 ++++++ .../global_objects/string/fontsize/index.html | 48 +++++ .../global_objects/string/fromcharcode/index.html | 50 ++++++ .../global_objects/string/fromcodepoint/index.html | 149 ++++++++++++++++ .../reference/global_objects/string/index.html | 194 +++++++++++++++++++++ .../global_objects/string/italics/index.html | 45 +++++ .../global_objects/string/link/index.html | 43 +++++ .../global_objects/string/repeat/index.html | 166 ++++++++++++++++++ .../global_objects/string/search/index.html | 49 ++++++ .../global_objects/string/slice/index.html | 51 ++++++ .../global_objects/string/small/index.html | 37 ++++ .../global_objects/string/strike/index.html | 44 +++++ .../reference/global_objects/string/sub/index.html | 44 +++++ .../global_objects/string/substr/index.html | 66 +++++++ .../global_objects/string/substring/index.html | 90 ++++++++++ .../reference/global_objects/string/sup/index.html | 45 +++++ .../global_objects/string/tolowercase/index.html | 40 +++++ .../global_objects/string/tosource/index.html | 41 +++++ .../global_objects/string/tostring/index.html | 41 +++++ .../global_objects/string/touppercase/index.html | 38 ++++ .../global_objects/string/valueof/index.html | 40 +++++ 28 files changed, 1719 insertions(+) create mode 100644 files/pl/web/javascript/reference/global_objects/string/anchor/index.html create mode 100644 files/pl/web/javascript/reference/global_objects/string/big/index.html create mode 100644 files/pl/web/javascript/reference/global_objects/string/blink/index.html create mode 100644 files/pl/web/javascript/reference/global_objects/string/bold/index.html create mode 100644 files/pl/web/javascript/reference/global_objects/string/charat/index.html create mode 100644 files/pl/web/javascript/reference/global_objects/string/charcodeat/index.html create mode 100644 files/pl/web/javascript/reference/global_objects/string/concat/index.html create mode 100644 files/pl/web/javascript/reference/global_objects/string/fontcolor/index.html create mode 100644 files/pl/web/javascript/reference/global_objects/string/fontsize/index.html create mode 100644 files/pl/web/javascript/reference/global_objects/string/fromcharcode/index.html create mode 100644 files/pl/web/javascript/reference/global_objects/string/fromcodepoint/index.html create mode 100644 files/pl/web/javascript/reference/global_objects/string/index.html create mode 100644 files/pl/web/javascript/reference/global_objects/string/italics/index.html create mode 100644 files/pl/web/javascript/reference/global_objects/string/link/index.html create mode 100644 files/pl/web/javascript/reference/global_objects/string/repeat/index.html create mode 100644 files/pl/web/javascript/reference/global_objects/string/search/index.html create mode 100644 files/pl/web/javascript/reference/global_objects/string/slice/index.html create mode 100644 files/pl/web/javascript/reference/global_objects/string/small/index.html create mode 100644 files/pl/web/javascript/reference/global_objects/string/strike/index.html create mode 100644 files/pl/web/javascript/reference/global_objects/string/sub/index.html create mode 100644 files/pl/web/javascript/reference/global_objects/string/substr/index.html create mode 100644 files/pl/web/javascript/reference/global_objects/string/substring/index.html create mode 100644 files/pl/web/javascript/reference/global_objects/string/sup/index.html create mode 100644 files/pl/web/javascript/reference/global_objects/string/tolowercase/index.html create mode 100644 files/pl/web/javascript/reference/global_objects/string/tosource/index.html create mode 100644 files/pl/web/javascript/reference/global_objects/string/tostring/index.html create mode 100644 files/pl/web/javascript/reference/global_objects/string/touppercase/index.html create mode 100644 files/pl/web/javascript/reference/global_objects/string/valueof/index.html (limited to 'files/pl/web/javascript/reference/global_objects/string') diff --git a/files/pl/web/javascript/reference/global_objects/string/anchor/index.html b/files/pl/web/javascript/reference/global_objects/string/anchor/index.html new file mode 100644 index 0000000000..737c385889 --- /dev/null +++ b/files/pl/web/javascript/reference/global_objects/string/anchor/index.html @@ -0,0 +1,56 @@ +--- +title: String.prototype.anchor() +slug: Web/JavaScript/Referencje/Obiekty/String/anchor +tags: + - JavaScript + - Method + - Prototype + - String +translation_of: Web/JavaScript/Reference/Global_Objects/String/anchor +--- +

{{JSRef}}

+ +

Podsumowanie

+ +

Tworzy kotwicę HTML {{HTMLElement("a")}} do użycia jako cel odnośnika.

+ +

Składnia

+ +
str.anchor(name)
+ +

Parametry

+ +
+
name
+
Łańcuch znaków.
+
+ +

Opis

+ +

Use the anchor() method to programmatically create and display an anchor in a document.

+ +

W składni łańcuch znaków reprezentuje literał tekstowy, który ma zobaczyć użytkownik. Łańcuch name reprezentuje atrybut name znacznika a.

+ +

Kotwice stworzone za pomocą metody anchor stają się elementami tablicy document.anchors.

+ +

Przykłady

+ +

Przykład: Zastosowanie anchor()

+ +

Następujący przykład wewnątrz kodu HTML elementu script:

+ +
var myString = "Tabela zawartości";
+
+document.body.innerHTML = myString.anchor("contents_anchor");
+
+ +

spowoduje otrzymanie na wyjściu kodu HTML:

+ +
<a name="contents_anchor">Tabela zawartości</a>
+
+ +

Zobacz także

+ + diff --git a/files/pl/web/javascript/reference/global_objects/string/big/index.html b/files/pl/web/javascript/reference/global_objects/string/big/index.html new file mode 100644 index 0000000000..62914dfa9c --- /dev/null +++ b/files/pl/web/javascript/reference/global_objects/string/big/index.html @@ -0,0 +1,43 @@ +--- +title: String.prototype.big() +slug: Web/JavaScript/Referencje/Obiekty/String/big +tags: + - Deprecated + - JavaScript + - Method + - Prototype + - String +translation_of: Web/JavaScript/Reference/Global_Objects/String/big +--- +
{{JSRef}} {{deprecated_header}}
+ +

Podsumowanie

+ +

Powoduje, iż łańcuch znaków zostanie wyświetlony jakby znajdował się wewnątrz znacznika {{HTMLElement("big")}}.

+ +

Składnia

+ +
str.big()
+ +

Opis

+ +

The big() method embeds a string in a <big> tag: "<big>str</big>".

+ +

Przykłady

+ +

Przykład: Zastosowanie big()

+ +

Następujący przykład stosuje metodę string do zmiany rozmiaru łańcucha znaków:

+ +
var worldString = "Witaj, Świecie";
+
+console.log(worldString.small());     // <small>Witaj, Świecie</small>
+console.log(worldString.big());       // <big>Witaj, Świecie</big>
+console.log(worldString.fontsize(7)); // <fontsize=7>Witaj, Świecie</fontsize>
+ +

Zobacz także

+ + diff --git a/files/pl/web/javascript/reference/global_objects/string/blink/index.html b/files/pl/web/javascript/reference/global_objects/string/blink/index.html new file mode 100644 index 0000000000..056dbc3792 --- /dev/null +++ b/files/pl/web/javascript/reference/global_objects/string/blink/index.html @@ -0,0 +1,50 @@ +--- +title: String.prototype.blink() +slug: Web/JavaScript/Referencje/Obiekty/String/blink +tags: + - Deprecated + - JavaScript + - Method + - Prototype + - String +translation_of: Web/JavaScript/Reference/Global_Objects/String/blink +--- +
{{JSRef}} {{deprecated_header}}
+ +

Podsumowanie

+ +

Powoduje, iż łańcuch będzie migotał tak, jakby był on wewnątrz znacznika {{HTMLElement("blink")}}.

+ +
+

Warning: Blinking text is frowned upon by several accessibility standards. The <blink> element itself is non-standard and deprecated!

+
+ +

Składnia

+ +
str.blink()
+ +

Opis

+ +

The blink() method embeds a string in a <blink> tag: "<blink>str</blink>".

+ +

Przykłady

+ +

Przykład: Zastosowanie blink()

+ +

Następujący przykład stosuje metodę string do zmiany formatowania łańcucha znaków:

+ +
var worldString="Witaj, Świecie";
+
+console.log(worldString.blink());   // <blink>Witaj, Świecie</blink>
+console.log(worldString.bold());    // <bold>Witaj, Świecie</bold>
+console.log(worldString.italics()); // <i>Witaj, Świecie</i>
+console.log(worldString.strike());  // <s>Witaj, Świecie</s>
+
+ +

Zobacz także

+ + diff --git a/files/pl/web/javascript/reference/global_objects/string/bold/index.html b/files/pl/web/javascript/reference/global_objects/string/bold/index.html new file mode 100644 index 0000000000..0708d5799e --- /dev/null +++ b/files/pl/web/javascript/reference/global_objects/string/bold/index.html @@ -0,0 +1,45 @@ +--- +title: String.prototype.bold() +slug: Web/JavaScript/Referencje/Obiekty/String/bold +tags: + - Deprecated + - JavaScript + - Method + - Prototype + - String +translation_of: Web/JavaScript/Reference/Global_Objects/String/bold +--- +

{{JSRef}}{{deprecated_header}}

+ +

Podsumowanie

+ +

Powoduje wyświetlenie łańcucha znaków jako pogrubienia, jakby był w znaczniku {{HTMLElement("b")}}.

+ +

Składnia

+ +
str.bold()
+ +

Opis

+ +

The bold() method embeds a string in a <b> tag: "<b>str</b>".

+ +

Przykłady

+ +

Przykład: Zastosowanie bold()

+ +

Następujący przykład stosuje metodę string do zmiany rozmiaru łańcucha znaków:

+ +
var worldString="Witaj, Świecie";
+
+console.log(worldString.blink());   // <blink>Witaj, Świecie</blink>
+console.log(worldString.bold());    // <bold>Witaj, Świecie</bold>
+console.log(worldString.italics()); // <i>Witaj, Świecie</i>
+console.log(worldString.strike());  // <s>Witaj, Świecie</s>
+ +

Zobacz także

+ + diff --git a/files/pl/web/javascript/reference/global_objects/string/charat/index.html b/files/pl/web/javascript/reference/global_objects/string/charat/index.html new file mode 100644 index 0000000000..30ce5303c2 --- /dev/null +++ b/files/pl/web/javascript/reference/global_objects/string/charat/index.html @@ -0,0 +1,68 @@ +--- +title: String.prototype.charAt() +slug: Web/JavaScript/Referencje/Obiekty/String/charAt +tags: + - JavaScript + - Method + - Prototype + - String +translation_of: Web/JavaScript/Reference/Global_Objects/String/charAt +--- +

{{JSRef}}

+ +

Podsumowanie

+ +

Zwraca określony znak z łańcucha znaków.

+ +

Składnia

+ +
str.charAt(index)
+ +

Parametry

+ +
+
index 
+
Liczba całkowita z przedziału od 0 do liczby o 1 mniejszej od długości łańcucha.
+
+ +

Opis

+ +

Znaki w łańcuchu znaków są indeksowane od lewej do prawej strony. Indeksem pierwszego znaku jest 0, a indeksem ostatniego znaku w łańcuchu znaków o nazwie stringName jest stringName.length - 1. Jeśli dostarczona wartość parametru index znajduje się poza zakresem, JavaScript zwróci pusty łańcuch znaków.

+ +

Przykłady

+ +

Przykład: Wyświetlanie różnych znaków z określonego łańcucha znaków

+ +

Poniższy przykład wyświetla różne znaki łańcucha "Brave new world":

+ +
var anyString="Brave new world";
+
+console.log("Znakiem o indeksie 0   jest '" + anyString.charAt(0)   + "'");
+console.log("Znakiem o indeksie 1   jest '" + anyString.charAt(1)   + "'");
+console.log("Znakiem o indeksie 2   jest '" + anyString.charAt(2)   + "'");
+console.log("Znakiem o indeksie 3   jest '" + anyString.charAt(3)   + "'");
+console.log("Znakiem o indeksie 4   jest '" + anyString.charAt(4)   + "'");
+console.log("Znakiem o indeksie 999 jest '" + anyString.charAt(999) + "'");
+
+ +

Powyższy kod wyświetli:

+ +
Znakiem o indeksie 0   jest 'B'
+Znakiem o indeksie 1   jest 'r'
+Znakiem o indeksie 2   jest 'a'
+Znakiem o indeksie 3   jest 'v'
+Znakiem o indeksie 4   jest 'e'
+Znakiem o indeksie 999 jest ''
+
+ +

Zobacz także

+ + diff --git a/files/pl/web/javascript/reference/global_objects/string/charcodeat/index.html b/files/pl/web/javascript/reference/global_objects/string/charcodeat/index.html new file mode 100644 index 0000000000..21c7822f12 --- /dev/null +++ b/files/pl/web/javascript/reference/global_objects/string/charcodeat/index.html @@ -0,0 +1,42 @@ +--- +title: String.prototype.charCodeAt() +slug: Web/JavaScript/Referencje/Obiekty/String/charCodeAt +tags: + - JavaScript + - Method + - Prototype + - String + - Unicode +translation_of: Web/JavaScript/Reference/Global_Objects/String/charCodeAt +--- +

{{JSRef}}

+ +

Podsumowanie

+ +

Zwraca liczbę oznaczającą wartość Unicode znaku o podanym indeksie.

+ +

Składnia

+ +
str.charCodeAt(index)
+ +

Parametry

+ +
+
index 
+
Liczba całkowita z przedziału od 0 do liczby o 1 mniejszej od długości łańcucha.
+
+ +

Opis

+ +

Wartości Unicode mieszczą się w zakresie od 0 do 65535. Pierwsze 128 wartości Unicode jest takie same jak w zbiorze znaków ASCII. Aby dowiedzieć się więcej o Unicode, zobacz Przewodnik po języku JavaScript.

+ +

Zgodność wsteczna: JavaScript 1.2 — Metoda charCodeAt zwraca liczbę wskazującą wartość ze zbioru kodowania ISO-Latin-1 znaku o podanym indeksie. Zbiór kodowania ISO-Latin-1 posiada zakres od 0 do 255. Znaki od 0 do 127 są identyczne, co te w zbiorze znaków ASCII.

+ +

Przykłady

+ +

Przykład: Zastosowanie charCodeAt()

+ +

Następujący przykład zwróci 65, wartość A w Unicode.

+ +
"ABC".charCodeAt(0); // zwróci 65
+
diff --git a/files/pl/web/javascript/reference/global_objects/string/concat/index.html b/files/pl/web/javascript/reference/global_objects/string/concat/index.html new file mode 100644 index 0000000000..b4361f0fd7 --- /dev/null +++ b/files/pl/web/javascript/reference/global_objects/string/concat/index.html @@ -0,0 +1,44 @@ +--- +title: String.prototype.concat() +slug: Web/JavaScript/Referencje/Obiekty/String/concat +tags: + - JavaScript + - Method + - Prototype + - String +translation_of: Web/JavaScript/Reference/Global_Objects/String/concat +--- +

{{JSRef}}

+ +

Podsumowanie

+ +

Łączy tekst dwóch lub więcej łańcuchów znaków i zwraca nowy łańcuch.

+ +

Składnia

+ +
str.concat(string2, string3[, ..., stringN])
+ +

Parametry

+ +
+
string2...string + N +  
+
Łańcuchy znaków mające być dołączone do tego łańcucha.
+
+ +

Opis

+ +

concat() łączy tekst jednego lub więcej łańcuchów znaków i zwraca nowy łańcuch znaków. Zmiana tekstu w jednym łańcuchu znaków nie ma wpływu na drugi łańcuch.

+ +

Przykłady

+ +

Przykład: Zastosowanie concat()

+ +

Następujący przykład łączy łańcuchy znaków w nowy łańcuch znaków.

+ +
var s1="Och, ";
+var s2="jaki piękny ";
+var s3="poranek.";
+var s4=s1.concat(s2,s3); // zwraca "Och, jaki piękny poranek."
+
diff --git a/files/pl/web/javascript/reference/global_objects/string/fontcolor/index.html b/files/pl/web/javascript/reference/global_objects/string/fontcolor/index.html new file mode 100644 index 0000000000..0cc7fa1ccc --- /dev/null +++ b/files/pl/web/javascript/reference/global_objects/string/fontcolor/index.html @@ -0,0 +1,50 @@ +--- +title: String.prototype.fontcolor() +slug: Web/JavaScript/Referencje/Obiekty/String/fontcolor +tags: + - Deprecated + - JavaScript + - Method + - Prototype + - String +translation_of: Web/JavaScript/Reference/Global_Objects/String/fontcolor +--- +
{{JSRef}} {{deprecated_header}}
+ +

Podsumowanie

+ +

Powoduje, iż łańcuch zostanie wyświetlony podanym kolorem tak jakby był wewnątrz znacznika {{HTMLElement("font")}}.

+ +

Składnia

+ +
str.fontcolor(color)
+ +

Parametry

+ +
+
color 
+
Łańcuch znaków wyrażający kolor jako trójka heksadecymalna RGB lub jako łańcuch znaków. Lista nazw w postaci łańcucha znaków dla kolorów jest dostępna w przewodniku po języku JavaScript 1.5.
+
+ +

Opis

+ +

Jeśli wyrażamy kolor w postaci trójki heksadecymalnej RGB, to musisz zastosować format rrggbb. Na przykład, wartość heksadecymalna koloru łososiowego składa się z red=FA, green=80 i blue=72, więc trójka RGB dla łososiowego będzie miała wartość "FA8072".

+ +

Przykłady

+ +

Przykład: Zastosowanie fontcolor()

+ +

Następujący przykład stosuje metodę string do zmiany koloru łańcucha znaków:

+ +
var worldString="Witaj, Świecie";
+
+console.log(worldString.fontcolor("red") + " jest koloru czerwonego w tej linii");
+// <font color="red">Witaj, Świecie</font> jest koloru czerwonego w tej linii
+
+console.log(worldString.fontcolor("FF00") +" linia jest czerwona i podany kolor heksadecymalny");
+// <font color="FF00">Witaj, Świecie</font> linia jest czerwona i podany kolor heksadecymalny
+
+ +
 
+ +

 

diff --git a/files/pl/web/javascript/reference/global_objects/string/fontsize/index.html b/files/pl/web/javascript/reference/global_objects/string/fontsize/index.html new file mode 100644 index 0000000000..3de3c5bb4c --- /dev/null +++ b/files/pl/web/javascript/reference/global_objects/string/fontsize/index.html @@ -0,0 +1,48 @@ +--- +title: String.prototype.fontsize() +slug: Web/JavaScript/Referencje/Obiekty/String/fontsize +tags: + - Deprecated + - JavaScript + - Method + - Prototype + - String +translation_of: Web/JavaScript/Reference/Global_Objects/String/fontsize +--- +

{{JSRef}}{{ Non-standard_header() }}

+ +

Podsumowanie

+ +

Powoduje wyświetlenie łańcucha znaków w określonym rozmiarze czcionki, tak jak to było w znaczniku {{HTMLElement("font")}}.

+ +

Składnia

+ +
str.fontsize(size)
+ +

Parametry

+ +
+
size 
+
Liczba całkowita pomiędzy 1 a 7, łańcuch znaków reprezentujący rozmiar znaku liczby całkowitej między 1 a 7.
+
+ +

Opis

+ +

Kiedy określisz rozmiar jako liczbę całkowitą, ustaw rozmiar stringName na jeden z 7 innych rozmiarów. Kiedy określisz size łańcucha znaków jako "-2", to dostosujesz rozmiar czcionki stringName relatywnie do rozmiaru jaki został ustawiony w znaczniku {{HTMLElement("basefont")}}.

+ +

Przykłady

+ +

Przykład: Zastosowanie fontsize()

+ +
var worldString = "Witaj, Świecie";
+
+console.log(worldString.small());     // <small>Witaj, Świecie</small>
+console.log(worldString.big());       // <big>Witaj, Świecie</big>
+console.log(worldString.fontsize(7)); // <fontsize=7>Witaj, Świecie</fontsize>
+ +

Zobacz także

+ + diff --git a/files/pl/web/javascript/reference/global_objects/string/fromcharcode/index.html b/files/pl/web/javascript/reference/global_objects/string/fromcharcode/index.html new file mode 100644 index 0000000000..7d00613db2 --- /dev/null +++ b/files/pl/web/javascript/reference/global_objects/string/fromcharcode/index.html @@ -0,0 +1,50 @@ +--- +title: String.fromCharCode() +slug: Web/JavaScript/Referencje/Obiekty/String/fromCharCode +tags: + - JavaScript + - Method + - String + - Unicode +translation_of: Web/JavaScript/Reference/Global_Objects/String/fromCharCode +--- +

{{JSRef}}

+ +

Podsumowanie

+ +

Zwraca łańcuch znaków stworzony przez podaną sekwencję kodów Unicode.

+ +

Składnia

+ +
String.fromCharCode(num1[, ...[, numN]])
+ +

Parametry

+ +
+
num1, ..., numN  
+
Sekwencja liczb, które są wartościami Unicode.
+
+ +

Opis

+ +

Ta metoda zwraca łańcuch znaków nie będący {{jsxref("String")}}.

+ +

Ponieważ fromCharCode() jest metodą statyczną {{jsxref("String")}}, używaj ją zawsze jako String.fromCharCode(), a nie jako metodę obiektu {{jsxref("String")}}.

+ +

Przykłady

+ +

Przykład: Zastosowanie fromCharCode()

+ +

Następujący przykład zwraca łańcuch znaków "ABC".

+ +
String.fromCharCode(65,66,67); // "ABC"
+
+ +

Zobacz także

+ + diff --git a/files/pl/web/javascript/reference/global_objects/string/fromcodepoint/index.html b/files/pl/web/javascript/reference/global_objects/string/fromcodepoint/index.html new file mode 100644 index 0000000000..a8c17af7f1 --- /dev/null +++ b/files/pl/web/javascript/reference/global_objects/string/fromcodepoint/index.html @@ -0,0 +1,149 @@ +--- +title: String.fromCodePoint() +slug: Web/JavaScript/Referencje/Obiekty/String/fromCodePoint +translation_of: Web/JavaScript/Reference/Global_Objects/String/fromCodePoint +--- +
{{JSRef}}
+ +

The static String.fromCodePoint() method returns a string created by using the specified sequence of code points.

+ +
{{EmbedInteractiveExample("pages/js/string-fromcodepoint.html","shorter")}}
+ + + +

Syntax

+ +
String.fromCodePoint(num1[, ...[, numN]])
+ +

Parameters

+ +
+
num1, ..., numN
+
A sequence of code points.
+
+ +

Return value

+ +

A string created by using the specified sequence of code points.

+ +

Exceptions

+ + + +

Description

+ +

This method returns a string (and not a {{jsxref("String")}} object).

+ +

Because fromCodePoint() is a static method of {{jsxref("String")}}, you must call it as String.fromCodePoint(), rather than as a method of a {{jsxref("String")}} object you created.

+ +

Polyfill

+ +

The String.fromCodePoint() method has been added to ECMAScript 2015 and may not be supported in all web browsers or environments yet.

+ +

Use the code below for a polyfill:

+ +
if (!String.fromCodePoint) (function(stringFromCharCode) {
+    var fromCodePoint = function(_) {
+      var codeUnits = [], codeLen = 0, result = "";
+      for (var index=0, len = arguments.length; index !== len; ++index) {
+        var codePoint = +arguments[index];
+        // correctly handles all cases including `NaN`, `-Infinity`, `+Infinity`
+        // The surrounding `!(...)` is required to correctly handle `NaN` cases
+        // The (codePoint>>>0) === codePoint clause handles decimals and negatives
+        if (!(codePoint < 0x10FFFF && (codePoint>>>0) === codePoint))
+          throw RangeError("Invalid code point: " + codePoint);
+        if (codePoint <= 0xFFFF) { // BMP code point
+          codeLen = codeUnits.push(codePoint);
+        } else { // Astral code point; split in surrogate halves
+          // https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
+          codePoint -= 0x10000;
+          codeLen = codeUnits.push(
+            (codePoint >> 10) + 0xD800,  // highSurrogate
+            (codePoint % 0x400) + 0xDC00 // lowSurrogate
+          );
+        }
+        if (codeLen >= 0x3fff) {
+          result += stringFromCharCode.apply(null, codeUnits);
+          codeUnits.length = 0;
+        }
+      }
+      return result + stringFromCharCode.apply(null, codeUnits);
+    };
+    try { // IE 8 only supports `Object.defineProperty` on DOM elements
+      Object.defineProperty(String, "fromCodePoint", {
+        "value": fromCodePoint, "configurable": true, "writable": true
+      });
+    } catch(e) {
+      String.fromCodePoint = fromCodePoint;
+    }
+}(String.fromCharCode));
+
+ +

Examples

+ +

Using fromCodePoint()

+ +

Valid input:

+ +
String.fromCodePoint(42);       // "*"
+String.fromCodePoint(65, 90);   // "AZ"
+String.fromCodePoint(0x404);    // "\u0404" == "Є"
+String.fromCodePoint(0x2F804);  // "\uD87E\uDC04"
+String.fromCodePoint(194564);   // "\uD87E\uDC04"
+String.fromCodePoint(0x1D306, 0x61, 0x1D307); // "\uD834\uDF06a\uD834\uDF07"
+
+ +

Invalid input:

+ +
String.fromCodePoint('_');      // RangeError
+String.fromCodePoint(Infinity); // RangeError
+String.fromCodePoint(-1);       // RangeError
+String.fromCodePoint(3.14);     // RangeError
+String.fromCodePoint(3e-2);     // RangeError
+String.fromCodePoint(NaN);      // RangeError
+
+ +

Compared to fromCharCode()

+ +

{{jsxref("String.fromCharCode()")}} cannot return supplementary characters (i.e. code points 0x0100000x10FFFF) by specifying their code point. Instead, it requires the UTF-16 surrogate pair in order to return a supplementary character:

+ +
String.fromCharCode(0xD83C, 0xDF03); // Code Point U+1F303 "Night with
+String.fromCharCode(55356, 57091);   // Stars" == "\uD83C\uDF03"
+
+ +

String.fromCodePoint(), on the other hand, can return 4-byte supplementary characters, as well as the more common 2-byte BMP characters, by specifying their code point (which is equivalent to the UTF-32 code unit):

+ +
String.fromCodePoint(0x1F303); // or 127747 in decimal
+
+ +

Specifications

+ + + + + + + + + + + + +
Specification
{{SpecName('ESDraft', '#sec-string.fromcodepoint', 'String.fromCodePoint')}}
+ +

Browser compatibility

+ + + +

{{Compat("javascript.builtins.String.fromCodePoint")}}

+ +

See also

+ + diff --git a/files/pl/web/javascript/reference/global_objects/string/index.html b/files/pl/web/javascript/reference/global_objects/string/index.html new file mode 100644 index 0000000000..ff27fbc81a --- /dev/null +++ b/files/pl/web/javascript/reference/global_objects/string/index.html @@ -0,0 +1,194 @@ +--- +title: String +slug: Web/JavaScript/Referencje/Obiekty/String +tags: + - JavaScript + - String +translation_of: Web/JavaScript/Reference/Global_Objects/String +--- +

{{JSRef}}

+ +

Podsumowanie

+ +

Tworzy obiekt pozwalający działać na ciągach znaków.

+ +

Składnia

+ +

Literały znakowe są postaci:

+ +
'string text'
+"string text"
+"中文 español English हिन्दी العربية português বাংলা русский 日本語 ਪੰਜਾਬੀ 한국어 தமிழ்"
+
+ +

Beside regular, printable characters, special characters can be encoded using escape notation:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
CodeOutput
\0the NUL character
\'single quote
\"double quote
\\backslash
\nnew line
\rcarriage return
\vvertical tab
\ttab
\bbackspace
\fform feed
\uXXXXunicode codepoint
\xXXthe Latin-1 character
+ +

Or, using the String global object directly:

+ +
String(thing)
+new String(thing)
+
+ +

Parametry

+ +
+
thing
+
Dowolny łańcuch znaków.
+
+ +

Opis

+ +

trings are useful for holding data that can be represented in text form. Some of the most-used operations on strings are to check their {{jsxref("String.length", "length")}}, to build and concatenate them using the + and += string operators, checking for the existence or location of substrings with the {{jsxref("String.prototype.indexOf()", "indexOf()")}} method, or extracting substrings with the {{jsxref("String.prototype.substring()", "substring()")}} method.

+ +

Character access

+ +

There are two ways to access an individual character in a string. The first is the {{jsxref("String.prototype.charAt()", "charAt()")}} method:

+ +
return 'cat'.charAt(1); // returns "a"
+ +
+ +

The other way (introduced in ECMAScript 5) is to treat the string as an array-like object, where individual characters correspond to a numerical index:

+ +
return 'cat'[1]; // returns "a"
+ +
+ +

For character access using bracket notation, attempting to delete or assign a value to these properties will not succeed. The properties involved are neither writable nor configurable. (See {{jsxref("Object.defineProperty()")}} for more information.)

+ +

Comparing strings

+ +

C developers have the strcmp() function for comparing strings. In JavaScript, you just use the less-than and greater-than operators:

+ +
var a = 'a';
+var b = 'b';
+if (a < b) { // true
+  print(a + ' is less than ' + b);
+} else if (a > b) {
+  print(a + ' is greater than ' + b);
+} else {
+  print(a + ' and ' + b + ' are equal.');
+}
+ +

A similar result can be achieved using the {{jsxref("String.prototype.localeCompare()", "localeCompare()")}} method inherited by String instances.

+ +

Distinction between string primitives and String objects

+ +

Note that JavaScript distinguishes between String objects and primitive string values. (The same is true of {{jsxref("Global_Objects/Boolean", "Boolean")}} and {{jsxref("Global_Objects/Number", "Numbers")}}.)

+ +

String literals (denoted by double or single quotes) and strings returned from String calls in a non-constructor context (i.e., without using the {{jsxref("Operators/new", "new")}} keyword) are primitive strings. JavaScript automatically converts primitives to String objects, so that it's possible to use String object methods for primitive strings. In contexts where a method is to be invoked on a primitive string or a property lookup occurs, JavaScript will automatically wrap the string primitive and call the method or perform the property lookup.

+ +
var s_prim = 'foo';
+var s_obj = new String(s_prim);
+
+console.log(typeof s_prim); // Logs "string"
+console.log(typeof s_obj);  // Logs "object"
+ +
+ +

String primitives and String objects also give different results when using {{jsxref("Global_Objects/eval", "eval()")}}. Primitives passed to eval are treated as source code; String objects are treated as all other objects are, by returning the object. For example:

+ +
var s1 = '2 + 2';             // creates a string primitive
+var s2 = new String('2 + 2'); // creates a String object
+console.log(eval(s1));        // returns the number 4
+console.log(eval(s2));        // returns the string "2 + 2"
+ +

For these reasons, code may break when it encounters String objects when it expects a primitive string instead, although generally authors need not worry about the distinction.

+ +

A String object can always be converted to its primitive counterpart with the {{jsxref("String.prototype.valueOf()", "valueOf()")}} method.

+ +
console.log(eval(s2.valueOf())); // returns the number 4
+ +
Note: For another possible approach to strings in JavaScript, please read the article about StringView — a C-like representation of strings based on typed arrays.
+ +

Własności

+ +
+
{{jsxref("String.prototype")}}
+
Pozwala na dodawanie własności do obiektu String.
+
+ +
{{jsOverrides("Function", "Properties", "prototype")}}
+ +

Metody

+ +
+
{{jsxref("String.fromCharCode()")}}
+
Zwraca łańcuch znaków stworzony przez podaną sekwencję kodów Unicode.
+
{{jsxref("String.fromCodePoint()")}} {{experimental_inline}}
+
Returns a string created by using the specified sequence of code points.
+
{{jsxref("String.raw()")}} {{experimental_inline}}
+
Returns a string created from a raw template string.
+
+ +
{{jsOverrides("Function", "Methods", "fromCharCode", "fromCodePoint", "raw")}}
+ +

Przykłady

+ +

Example: String conversion

+ +

It's possible to use String as a "safer" {{jsxref("String.prototype.toString()", "toString()")}} alternative, as although it still normally calls the underlying toString(), it also works for {{jsxref("null")}} and {{jsxref("undefined")}}. For example:

+ +
var outputStrings = [];
+for (var i = 0, n = inputValues.length; i < n; ++i) {
+  outputStrings.push(String(inputValues[i]));
+}
diff --git a/files/pl/web/javascript/reference/global_objects/string/italics/index.html b/files/pl/web/javascript/reference/global_objects/string/italics/index.html new file mode 100644 index 0000000000..016a400805 --- /dev/null +++ b/files/pl/web/javascript/reference/global_objects/string/italics/index.html @@ -0,0 +1,45 @@ +--- +title: String.prototype.italics() +slug: Web/JavaScript/Referencje/Obiekty/String/italics +tags: + - Deprecated + - JavaScript + - Method + - Prototype + - String +translation_of: Web/JavaScript/Reference/Global_Objects/String/italics +--- +

{{JSRef}}{{deprecated_header}}

+ +

Podsumowanie

+ +

Powoduje, iż łańcuch zostanie wyświetlony kursywą tak jakby był wewnątrz znacznika {{HTMLElement("i")}}.

+ +

Składnia

+ +
str.italics()
+ +

Opis

+ +

The italics() method embeds a string in an <i> tag: "<i>str</i>".

+ +

Przykłady

+ +

Przykład: Zastosowanie metody italics()

+ +

Następujący przykład stosuje metodę string do zmiany formatowania łańcucha znakowego:

+ +
var worldString="Witaj, Świecie";
+
+console.log(worldString.blink());   // <blink>Witaj, Świecie</blink>
+console.log(worldString.bold());    // <bold>Witaj, Świecie</bold>
+console.log(worldString.italics()); // <i>Witaj, Świecie</i>
+console.log(worldString.strike());  // <s>Witaj, Świecie</s>
+ +

Zobacz także

+ + diff --git a/files/pl/web/javascript/reference/global_objects/string/link/index.html b/files/pl/web/javascript/reference/global_objects/string/link/index.html new file mode 100644 index 0000000000..6d8baeb078 --- /dev/null +++ b/files/pl/web/javascript/reference/global_objects/string/link/index.html @@ -0,0 +1,43 @@ +--- +title: String.prototype.link() +slug: Web/JavaScript/Referencje/Obiekty/String/link +tags: + - JavaScript + - Method + - Prototype + - String +translation_of: Web/JavaScript/Reference/Global_Objects/String/link +--- +

{{JSRef}}

+ +

Podsumowanie

+ +

Tworzy łącze hipertekstowe, które wywołuje inny URL.

+ +

Składnia

+ +
str.link(url)
+ +

Parametry

+ +
+
url
+
Jakikolwiek łańcuch określony w href ze znacznika a; powinien być umieszczany poprawny URL (relatywny lub absolutny).
+
+ +

Opis

+ +

Linki tworzymy poprzez metodę link stającą się elementami tablicy links z obiektu document. Zobacz document.links.

+ +

Przykłady

+ + + +

Następujący przykład wyświetla słowo "MDN" jako odnośnik hipertekstowy, poprzez który użytkownik będzie mógł przejść na stronę domową Netscape:

+ +
var hotText="MDN";
+var URL="https://developer.mozilla.org/";
+
+console.log("Kliknij, aby powrócić do " + hotText.link(URL));
+// Kliknij, aby powrócić do <a href="https://developer.mozilla.org">MDN</a>
+
diff --git a/files/pl/web/javascript/reference/global_objects/string/repeat/index.html b/files/pl/web/javascript/reference/global_objects/string/repeat/index.html new file mode 100644 index 0000000000..76bf932753 --- /dev/null +++ b/files/pl/web/javascript/reference/global_objects/string/repeat/index.html @@ -0,0 +1,166 @@ +--- +title: String.prototype.repeat() +slug: Web/JavaScript/Referencje/Obiekty/String/repeat +translation_of: Web/JavaScript/Reference/Global_Objects/String/repeat +--- +
{{JSRef}}
+ +

The repeat() method constructs and returns a new string which contains the specified number of copies of the string on which it was called, concatenated together.

+ +

Składnia

+ +
str.repeat(count)
+ +

Parametry

+ +
+
count
+
An integer between 0 and +∞: [0, +∞), indicating the number of times to repeat the string in the newly-created string that is to be returned.
+
+ +

Zwracana wartość

+ +

A new string containing the specified number of copies of the given string.

+ +

Exceptions

+ + + +

Przykłady

+ +
'abc'.repeat(-1);   // RangeError
+'abc'.repeat(0);    // ''
+'abc'.repeat(1);    // 'abc'
+'abc'.repeat(2);    // 'abcabc'
+'abc'.repeat(3.5);  // 'abcabcabc' (count will be converted to integer)
+'abc'.repeat(1/0);  // RangeError
+
+({ toString: () => 'abc', repeat: String.prototype.repeat }).repeat(2);
+// 'abcabc' (repeat() is a generic method)
+
+ +

Polyfill

+ +

This method has been added to the ECMAScript 6 specification and may not be available in all JavaScript implementations yet. However, you can polyfill String.prototype.repeat() with the following snippet:

+ +
if (!String.prototype.repeat) {
+  String.prototype.repeat = function(count) {
+    'use strict';
+    if (this == null) {
+      throw new TypeError('can\'t convert ' + this + ' to object');
+    }
+    var str = '' + this;
+    count = +count;
+    if (count != count) {
+      count = 0;
+    }
+    if (count < 0) {
+      throw new RangeError('repeat count must be non-negative');
+    }
+    if (count == Infinity) {
+      throw new RangeError('repeat count must be less than infinity');
+    }
+    count = Math.floor(count);
+    if (str.length == 0 || count == 0) {
+      return '';
+    }
+    // Ensuring count is a 31-bit integer allows us to heavily optimize the
+    // main part. But anyway, most current (August 2014) browsers can't handle
+    // strings 1 << 28 chars or longer, so:
+    if (str.length * count >= 1 << 28) {
+      throw new RangeError('repeat count must not overflow maximum string size');
+    }
+    var rpt = '';
+    for (;;) {
+      if ((count & 1) == 1) {
+        rpt += str;
+      }
+      count >>>= 1;
+      if (count == 0) {
+        break;
+      }
+      str += str;
+    }
+    // Could we try:
+    // return Array(count + 1).join(this);
+    return rpt;
+  }
+}
+
+ +

Specifications

+ + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('ES6', '#sec-string.prototype.repeat', 'String.prototype.repeat')}}{{Spec2('ES6')}}Initial definition.
{{SpecName('ESDraft', '#sec-string.prototype.repeat', 'String.prototype.repeat')}}{{Spec2('ESDraft')}} 
+ +

Browser compatibility

+ +
{{CompatibilityTable}}
+ +
+ + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support{{CompatChrome("41")}} {{CompatGeckoDesktop("24")}}{{CompatNo}}{{CompatNo}}{{CompatSafari("9")}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{CompatNo}}{{CompatChrome("36")}}{{CompatGeckoMobile("24")}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
+
diff --git a/files/pl/web/javascript/reference/global_objects/string/search/index.html b/files/pl/web/javascript/reference/global_objects/string/search/index.html new file mode 100644 index 0000000000..29b9d8e8fb --- /dev/null +++ b/files/pl/web/javascript/reference/global_objects/string/search/index.html @@ -0,0 +1,49 @@ +--- +title: String.prototype.search() +slug: Web/JavaScript/Referencje/Obiekty/String/search +tags: + - JavaScript + - Method + - Prototype + - String +translation_of: Web/JavaScript/Reference/Global_Objects/String/search +--- +

{{JSRef}}

+ +

Podsumowanie

+ +

Wykonuje przeszukanie dla dopasowanych wyrażeń regularnych i tego obiektu {{jsxref("String")}}.

+ +

Składnia

+ +
str.search(regexp)
+ +

Parametry

+ +
+
regexp 
+
Nazwa wyrażenia regularnego. Może być to nazwa zmiennej lub literał.
+
+ +

Opis

+ +

Jeśli sukces, rezultat przeszukania indeksu wyrażenia regularnego wewnątrz łańcucha znaków. Inaczej zwróci -1.

+ +

Kiedy chcesz wiedzieć gdzie jest znaleziony wzorzec w łańcuchu znaków zastosuj search() (podobne do wyrażenia regularnego metody {{jsxref("RegExp.prototype.test()", "test()")}}); aby uzyskać więcej informacji (lecz wolniej wykonywanie) zastosuj {{jsxref("String.prototype.match()", "match()")}} (podobne do wyrażenia regularnego metody {{jsxref("RegExp.prototype.exec()", "exec()")}} method).

+ +

Przykłady

+ + + +

Następujący przykład drukuje wiadomość, która zależy od sukcesu testu.

+ +
function testinput(re, str){
+   var midstring;
+   if (str.search(re) != -1) {
+      midstring = " contains ";
+   } else {
+      midstring = " does not contain ";
+   }
+   console.log (str + midstring + re.source);
+}
+
diff --git a/files/pl/web/javascript/reference/global_objects/string/slice/index.html b/files/pl/web/javascript/reference/global_objects/string/slice/index.html new file mode 100644 index 0000000000..4fca8a78ca --- /dev/null +++ b/files/pl/web/javascript/reference/global_objects/string/slice/index.html @@ -0,0 +1,51 @@ +--- +title: String.prototype.slice() +slug: Web/JavaScript/Referencje/Obiekty/String/slice +tags: + - JavaScript + - Method + - Prototype + - String +translation_of: Web/JavaScript/Reference/Global_Objects/String/slice +--- +

{{JSRef}}

+ +

Podsumowanie

+ +

Wydobywa część łańcucha znaków i zwraca go jako nowy łańcuch znaków.

+ +

Składnia

+ +
str.slice(beginSlice[, endSlice])
+ +

Parametry

+ +
+
beginSlice 
+
Oparty na zerze początek indeksu rozpoczynający wyciąganie.
+
+ +
+
endSlice 
+
Oparty na zerze początek indeksu, który kończy wyciąganie. Jeśli pominięty slice() wydobywa do końca łańcuch znaków.
+
+ +

Opis

+ +

slice() wyciąga tekst z jednego łańcucha znaków i zwraca nowy łańcuch znaków. Zmiany w treści jednego łańcucha znaków nie mają wpływu na drugi.

+ +

slice() wyciąga tekst do endSlice lecz go nie włącza. string.slice(1,4) wyciąga drugi znak aż do czwartego (znaki o indeksach 1, 2 i 3).

+ +

Jako ujemny indeks endSlice sygnalizuje przesunięcie z końca łańcucha znaków. str.slice(2,-1) wyciąga trzeci przez ostatni znak w łańcuchu znaków.

+ +

Przykłady

+ +

Przykład: Zastosowanie slice()

+ +

Poniższy przykład używa slice do stworzenia nowego łańcucha znaków.

+ +
var str1 = 'The morning is upon us.';
+var str2 = str1.slice(4,-2);
+
+console.log(str2); // OUTPUT: morning is upon u
+
diff --git a/files/pl/web/javascript/reference/global_objects/string/small/index.html b/files/pl/web/javascript/reference/global_objects/string/small/index.html new file mode 100644 index 0000000000..be9d33a5bb --- /dev/null +++ b/files/pl/web/javascript/reference/global_objects/string/small/index.html @@ -0,0 +1,37 @@ +--- +title: String.prototype.small() +slug: Web/JavaScript/Referencje/Obiekty/String/small +tags: + - JavaScript +translation_of: Web/JavaScript/Reference/Global_Objects/String/small +--- +
{{JSRef}} {{deprecated_header}}
+ +

Podsumowanie

+ +

Powoduje to, że łańcuch znaków będzie wyświetlany małą czcionką, jakby znajdował się wewnątrz znacznika {{HTMLElement("small")}}.

+ +

Składnia

+ +
str.small()
+ +

Opis

+ +

The small() method embeds a string in a <small> tag: "<small>str</small>".

+ +

Przykłady

+ +

Przykład: Zastosowanie metody small()

+ +
var worldString = "Witaj, Świecie";
+
+console.log(worldString.small());     // <small>Witaj, Świecie</small>
+console.log(worldString.big());       // <big>Witaj, Świecie</big>
+console.log(worldString.fontsize(7)); // <fontsize=7>Witaj, Świecie</fontsize>
+ +

Zobacz także

+ + diff --git a/files/pl/web/javascript/reference/global_objects/string/strike/index.html b/files/pl/web/javascript/reference/global_objects/string/strike/index.html new file mode 100644 index 0000000000..cef74018f1 --- /dev/null +++ b/files/pl/web/javascript/reference/global_objects/string/strike/index.html @@ -0,0 +1,44 @@ +--- +title: String.prototype.strike() +slug: Web/JavaScript/Referencje/Obiekty/String/strike +tags: + - JavaScript + - Method + - Prototype + - String +translation_of: Web/JavaScript/Reference/Global_Objects/String/strike +--- +

{{JSRef}}{{deprecated_header}}

+ +

Podsumowanie

+ +

Powoduje, iż łańcuch zostanie wyświetlony przekreślony, tak jakby był wewnątrz znacznika {{HTMLElement("strike")}}.

+ +

Składnia

+ +
str.strike()
+ +

Opis

+ +

The strike() method embeds a string in a <strike> tag: "<strike>str</strike>".

+ +

Przykłady

+ +

Przykład: Zastosowanie metody strike()

+ +

Następujący przykład stosuje metodę string do zmiany formatowania łańcucha znakowego:

+ +
var worldString="Witaj, Świecie";
+
+console.log(worldString.blink());   // <blink>Witaj, Świecie</blink>
+console.log(worldString.bold());    // <bold>Witaj, Świecie</bold>
+console.log(worldString.italics()); // <i>Witaj, Świecie</i>
+console.log(worldString.strike());  // <s>Witaj, Świecie</s>
+ +

Zobacz także

+ + diff --git a/files/pl/web/javascript/reference/global_objects/string/sub/index.html b/files/pl/web/javascript/reference/global_objects/string/sub/index.html new file mode 100644 index 0000000000..4c36c53a39 --- /dev/null +++ b/files/pl/web/javascript/reference/global_objects/string/sub/index.html @@ -0,0 +1,44 @@ +--- +title: String.prototype.sub() +slug: Web/JavaScript/Referencje/Obiekty/String/sub +tags: + - JavaScript + - Method + - Prototype + - String +translation_of: Web/JavaScript/Reference/Global_Objects/String/sub +--- +

{{JSRef}}{{deprecated_header}}

+ +

Podsumowanie

+ +

Powoduje, iż łańcuch zostanie wyświetlony jako indeks dolny tak jakby był wewnątrz znacznika {{HTMLElement("sub")}}.

+ +

Składnia

+ +
str.sub()
+ +

Opis

+ +

The sub() method embeds a string in a <sub> tag: "<sub>str</sub>".

+ +

Przykłady

+ +

Przykład: Zastosowanie metod sub() i sup()

+ +

Następujący przykład stosuje metody sub() i {{jsxref("String.prototype.sup()", "sup()")}} do formatowania łańcucha znaków:

+ +
var superText="superscript";
+var subText="subscript";
+
+console.log("This is what a " + superText.sup() + " looks like.");
+// This is what a <sup>superscript</sup> looks like
+
+console.log("This is what a " + subText.sub() + " looks like.");
+// This is what a <sub>subscript</sub> looks like.
+ +

Zobacz także

+ + diff --git a/files/pl/web/javascript/reference/global_objects/string/substr/index.html b/files/pl/web/javascript/reference/global_objects/string/substr/index.html new file mode 100644 index 0000000000..61487db384 --- /dev/null +++ b/files/pl/web/javascript/reference/global_objects/string/substr/index.html @@ -0,0 +1,66 @@ +--- +title: String.prototype.substr() +slug: Web/JavaScript/Referencje/Obiekty/String/substr +tags: + - JavaScript + - Method + - Prototype + - String +translation_of: Web/JavaScript/Reference/Global_Objects/String/substr +--- +

{{JSRef}}

+ +

Podsumowanie

+ +

Zwraca określoną liczbę początkowych znaków w łańcuchu znaków w określonej lokalizacji.

+ +

Składnia

+ +
str.substr(start[, length])
+ +

Parametry

+ +
+
start 
+
Lokalizacja, w której rozpoczyna się wyciąganie znaków (wartość liczbowa pomiędzy 0, a jeden znak mniej niż długość łańcucha znaków).
+
+ +
+
length 
+
Liczba znaków do wyciągnięcia.
+
+ +

Opis

+ +

start jest indeksem znaków. Pierwszym znakiem w indeksie jest 0 i ostatnim znakiem w indeksie jest liczba o 1 mniejsza niż długość łańcucha znaków. substr() rozpoczyna wyciąganie znaków w start i ściąga liczbę length znaków.

+ +

Jeśli start jest dodatnie i jest długością łańcucha znaków lub dłuższą wartością, substr() nie zwraca znaków.

+ +

Jeśli start jest ujemne, substr() stosuje to jako indeks znaków z końca łańcucha znaków. Jeśli start jest ujemne i abs(start) jest większe niż długość łańcucha znaków to substr() stosuje 0 jako początek indeksu.

+ +

Jeśli length jest 0 lub ujemne, substr() nie zwróci znaków. Jeśli length jest opuszczone, substr() wyciągnie znaki aż do końca łańcucha znaków.

+ +

Przykłady

+ +

Przykład: Zastosowanie substr()

+ +

Rozpatrz poniższy skrypt:

+ +
var str = 'abcdefghij';
+
+console.log('(1, 2): ' + str.substr(1, 2)); // '(1, 2): bc'
+console.log('(-3, 2): ' + str.substr(-3, 2)); // '(-3, 2): hi'
+console.log('(-3): ' + str.substr(-3)); // '(-3): hij'
+console.log('(1): ' + str.substr(1)); // '(1): bcdefghij'
+console.log('(-20, 2): ' + str.substr(-20, 2)); // '(-20, 2): ab'
+console.log('(20, 2): ' + str.substr(20, 2)); // '(20, 2): '
+
+ +

Zobacz także

+ +

 

+ + diff --git a/files/pl/web/javascript/reference/global_objects/string/substring/index.html b/files/pl/web/javascript/reference/global_objects/string/substring/index.html new file mode 100644 index 0000000000..5a446e0225 --- /dev/null +++ b/files/pl/web/javascript/reference/global_objects/string/substring/index.html @@ -0,0 +1,90 @@ +--- +title: String.prototype.substring() +slug: Web/JavaScript/Referencje/Obiekty/String/substring +tags: + - JavaScript + - Method + - Prototype + - String +translation_of: Web/JavaScript/Reference/Global_Objects/String/substring +--- +

{{JSRef}}

+ +

Podsumowanie

+ +

Zwraca podciąg obiektu String.

+ +

Składnia

+ +
str.substring(indexA[, indexB])
+ +

Parametry

+ +
+
indexA 
+
Liczba całkowita pomiędzy 0, a liczbą o jeden mniejszą niż długość łańcucha znaków.
+
indexB 
+
Opcjonalny. Liczba całkowita pomiędzy 0 i długością łańcucha znaków.
+
+ +

Opis

+ +

substring urywa znaki z indexA lecz nie włącza ich do indexB. W szczególności:

+ + + +

Jeśli indexA jest większy niż indexB, JavaScript zwróci substring(indexB, indexA).

+ +

Przykłady

+ +

Przykład: Zastosowanie substring()

+ +

Następujący przykład substring stosujemy do wyświetlenia znaków ze słowa "Mozilla":

+ +
var anyString = "Mozilla";
+
+// Wyświetli  "Moz"
+console.log(anyString.substring(0,3));
+console.log(anyString.substring(3,0));
+
+// Wyświetli  "lla"
+console.log(anyString.substring(4));
+console.log(anyString.substring(4,7));
+console.log(anyString.substring(7,4));
+
+// Wyświetli  "Mozill"
+console.log(anyString.substring(0,6));
+
+// Wyświetli "Mozilla"
+console.log(anyString.substring(0,7));
+console.log(anyString.substring(0,10));
+
+ +

Przykład: Zamiana podciągu wewnątrz ciągu

+ +

Następujący przykład zamienia podciąg wewnątrz ciągu. Zostaną zamienione oba poszczególne znaki i podciągi. Funkcja zostanie wywołana na koniec przykładu zmieniając łańcuch znaków; "Brave New World" na "Brave New Web".

+ +
function replaceString(oldS, newS, fullS) {
+// Replaces oldS with newS in the string fullS
+   for (var i = 0; i < fullS.length; i++) {
+      if (fullS.substring(i, i + oldS.length) == oldS) {
+         fullS = fullS.substring(0, i) + newS + fullS.substring(i + oldS.length, fullS.length);
+      }
+   }
+   return fullS;
+}
+
+replaceString("World", "Web", "Brave New World");
+
+ +

Zobacz także

+ + diff --git a/files/pl/web/javascript/reference/global_objects/string/sup/index.html b/files/pl/web/javascript/reference/global_objects/string/sup/index.html new file mode 100644 index 0000000000..dbf33ea3ed --- /dev/null +++ b/files/pl/web/javascript/reference/global_objects/string/sup/index.html @@ -0,0 +1,45 @@ +--- +title: String.prototype.sup() +slug: Web/JavaScript/Referencje/Obiekty/String/sup +tags: + - Deprecated + - JavaScript + - Method + - Prototype + - String +translation_of: Web/JavaScript/Reference/Global_Objects/String/sup +--- +

{{JSRef}}{{deprecated_header}}

+ +

Podsumowanie

+ +

Powoduje, iż łańcuch zostanie wyświetlony jako indeks górny tak jakby był wewnątrz znacznika {{HTMLElement("sup")}}.

+ +

Składnia

+ +
str.sup()
+ +

Opis

+ +

The sup() method embeds a string in a <sup> tag: "<sup>str</sup>".

+ +

Przykłady

+ +

Przykład: Zastosowanie metody sub() i sup()

+ +

Następujący przykład stosuje metodę {{jsxref("String.prototype.sub()", "sub()")}} i sup() do zmiany formatu łańcucha znaków:

+ +
var superText="superscript";
+var subText="subscript";
+
+console.log("This is what a " + superText.sup() + " looks like.");
+// This is what a <sup>superscript</sup> looks like
+
+console.log("This is what a " + subText.sub() + " looks like.");
+// This is what a <sub>subscript</sub> looks like.
+ +

Zobacz także

+ + diff --git a/files/pl/web/javascript/reference/global_objects/string/tolowercase/index.html b/files/pl/web/javascript/reference/global_objects/string/tolowercase/index.html new file mode 100644 index 0000000000..0b871b9ca6 --- /dev/null +++ b/files/pl/web/javascript/reference/global_objects/string/tolowercase/index.html @@ -0,0 +1,40 @@ +--- +title: String.prototype.toLowerCase() +slug: Web/JavaScript/Referencje/Obiekty/String/toLowerCase +tags: + - JavaScript + - Method + - Prototype + - String +translation_of: Web/JavaScript/Reference/Global_Objects/String/toLowerCase +--- +

{{jsref}}

+ +

Podsumowanie

+ +

Zwraca wartość wywołującego łańcucha znaków, skonwertowaną na małe litery.

+ +

Składnia

+ +
str.toLowerCase()
+ +

Opis

+ +

Metoda toLowerCase() zwraca wartość łańcucha znaków skonwertowanego na małe litery. toLowerCase() nie wpływa na wartość samego łańcucha.

+ +

Przykłady

+ +

Przykład: Zastosowanie toLowerCase

+ +

Następujący przykład wyświetli łańcuch "alfabet" złożony z małych liter:

+ +
console.log('ALFABET'.toLowerCase()); // 'alfabet'
+
+ +

Zobacz także

+ + diff --git a/files/pl/web/javascript/reference/global_objects/string/tosource/index.html b/files/pl/web/javascript/reference/global_objects/string/tosource/index.html new file mode 100644 index 0000000000..cb372d673c --- /dev/null +++ b/files/pl/web/javascript/reference/global_objects/string/tosource/index.html @@ -0,0 +1,41 @@ +--- +title: String.prototype.toSource() +slug: Web/JavaScript/Referencje/Obiekty/String/toSource +tags: + - JavaScript + - Method + - Non-standard + - Prototype + - String +translation_of: Web/JavaScript/Reference/Global_Objects/String/toSource +--- +

{{JSRef}}{{non-standard_header}}

+ +

Podsumowanie

+ +

Zwraca łańcuch znaków reprezentujący kod źródłowy obiektu.

+ +

Składnia

+ +
String.toSource()
+str.toSource()
+
+ +

Opis

+ +

Metoda toSource() zwraca następujące wartości:

+ + + +

Ta metoda jest w JavaScript wywoływana zazwyczaj wewnętrznie, nie bezpośrednio w kodzie.

+ +
 
diff --git a/files/pl/web/javascript/reference/global_objects/string/tostring/index.html b/files/pl/web/javascript/reference/global_objects/string/tostring/index.html new file mode 100644 index 0000000000..16028dff15 --- /dev/null +++ b/files/pl/web/javascript/reference/global_objects/string/tostring/index.html @@ -0,0 +1,41 @@ +--- +title: String.protype.toString() +slug: Web/JavaScript/Referencje/Obiekty/String/toString +tags: + - JavaScript + - Method + - Prototype + - String +translation_of: Web/JavaScript/Reference/Global_Objects/String/toString +--- +

{{JSRef}}

+ +

Podsumowanie

+ +

Zwraca łańcuch znaków reprezentujący dany obiekt.

+ +

Składnia

+ +
str.toString()
+ +

Opis

+ +

Obiekt {{jsxref("String")}} przesłania metodę toString obiektu {{jsxref("Object")}}; nie dziedziczy {{jsxref("Object.prototype.toString()")}}. Dla obiektów {{jsxref("String")}}, metoda toString() zwraca łańcuch znaków reprezentujący obiekt.

+ +

Przykłady

+ +

Przykład: Zastosowanie toString()

+ +

Następujący przykład wyświetli wartość łańcuch znaków obiektu {{jsxref("String")}}:

+ +
var x = new String("Witaj świecie");
+
+console.log(x.toString())      // Wyświetla "Witaj świecie"
+
+ +

Zobacz także

+ + diff --git a/files/pl/web/javascript/reference/global_objects/string/touppercase/index.html b/files/pl/web/javascript/reference/global_objects/string/touppercase/index.html new file mode 100644 index 0000000000..4b792076fe --- /dev/null +++ b/files/pl/web/javascript/reference/global_objects/string/touppercase/index.html @@ -0,0 +1,38 @@ +--- +title: String.prototype.toUpperCase() +slug: Web/JavaScript/Referencje/Obiekty/String/toUpperCase +tags: + - JavaScript + - Method + - Prototype + - String +translation_of: Web/JavaScript/Reference/Global_Objects/String/toUpperCase +--- +

{{JSRef}}

+ +

Podsumowanie

+ +

Zwraca wartość wywołującego łańcucha znaków, skonwertowaną na duże litery.

+ +

Składnia

+ +
str.toUpperCase()
+ +

Opis

+ +

Metoda toUpperCase() zwraca wartość łańcucha znaków skonwertowanego na duże litery. toUpperCase() nie wpływa na wartość samego łańcucha.

+ +

Przykłady

+ +

Przykład: Zastosowanie toUpperCase()

+ +
console.log('alfabet'.toUpperCase()); // 'ALFABET'
+
+ +

Zobacz także

+ + diff --git a/files/pl/web/javascript/reference/global_objects/string/valueof/index.html b/files/pl/web/javascript/reference/global_objects/string/valueof/index.html new file mode 100644 index 0000000000..1eda0e3021 --- /dev/null +++ b/files/pl/web/javascript/reference/global_objects/string/valueof/index.html @@ -0,0 +1,40 @@ +--- +title: String.prototype.valueOf() +slug: Web/JavaScript/Referencje/Obiekty/String/valueOf +tags: + - JavaScript + - Method + - Property + - String +translation_of: Web/JavaScript/Reference/Global_Objects/String/valueOf +--- +

{{JSRef}}

+ +

Podsumowanie

+ +

Zwraca pierwotną wartość obiektu {{jsxref("String")}}.

+ +

Składnia

+ +
str.valueOf()
+ +

Opis

+ +

Metoda valueOf() obiektu {{jsxref("String")}} zwraca pierwotną wartość obiektu {{jsxref("String")}} jako łańcuch znaków. Ta wartość jest równoważna do {{jsxref("String.prototype.toString()")}}.

+ +

Ta metoda jest w JavaScript wywoływana zazwyczaj wewnętrznie, nie bezpośrednio w kodzie.

+ +

Przykłady

+ +

Przykład: Zastosowanie valueOf()

+ +
var x = new String("Witaj świecie");
+console.log(x.valueOf()); // Wyświetla "Witaj świecie"
+
+ +

Zobacz także

+ + -- cgit v1.2.3-54-g00ecf