Skip to content

Commit f380c0b

Browse files
string#quotes
1 parent badc904 commit f380c0b

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

1-js/05-data-types/03-string/article.md

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
# Strings
1+
# Łańcuchy
22

3-
In JavaScript, the textual data is stored as strings. There is no separate type for a single character.
3+
W JavaScript dane tekstowe są przechowywane jako łańcuchy (ciągi znaków). Nie ma oddzielnego typu dla pojedynczego znaku.
44

5-
The internal format for strings is always [UTF-16](https://en.wikipedia.org/wiki/UTF-16), it is not tied to the page encoding.
5+
Wewnętrzny format ciągów to zawsze [UTF-16](https://pl.wikipedia.org/wiki/UTF-16), nie jest on powiązany z kodowaniem strony
66

7-
## Quotes
7+
## Cytaty
88

9-
Let's recall the kinds of quotes.
9+
W JavaScript istnieją różne rodzaje cudzysłowów.
1010

11-
Strings can be enclosed within either single quotes, double quotes or backticks:
11+
Ciąg można utworzyć za pomocą cudzysłowów pojedynczych, podwójnych lub grawisów:
1212

1313
```js
1414
let single = 'single-quoted';
@@ -17,7 +17,7 @@ let double = "double-quoted";
1717
let backticks = `backticks`;
1818
```
1919

20-
Single and double quotes are essentially the same. Backticks, however, allow us to embed any expression into the string, by wrapping it in `${…}`:
20+
Pojedyncze i podwójne cudzysłowy są zasadniczo takie same. Grawisy natomiast pozwalają nam osadzić dowolne wyrażenie w łańcuchu, owijając je w `${…}`:
2121

2222
```js run
2323
function sum(a, b) {
@@ -27,7 +27,7 @@ function sum(a, b) {
2727
alert(`1 + 2 = ${sum(1, 2)}.`); // 1 + 2 = 3.
2828
```
2929

30-
Another advantage of using backticks is that they allow a string to span multiple lines:
30+
Kolejną zaletą grawisów jest to, że mogą obejmować więcej niż jedną linię, na przykład:
3131

3232
```js run
3333
let guestList = `Guests:
@@ -36,21 +36,19 @@ let guestList = `Guests:
3636
* Mary
3737
`;
3838

39-
alert(guestList); // a list of guests, multiple lines
39+
alert(guestList); // lista gości, wiele wierszy
4040
```
4141

42-
Looks natural, right? But single or double quotes do not work this way.
43-
44-
If we use them and try to use multiple lines, there'll be an error:
42+
Wygląda całkiem naturalnie, prawda? Jeśli jednak spróbujesz użyć pojedynczych lub podwójnych cudzysłowów w ten sam sposób, wystąpi błąd:
4543

4644
```js run
4745
let guestList = "Guests: // Error: Unexpected token ILLEGAL
4846
* John";
4947
```
5048

51-
Single and double quotes come from ancient times of language creation when the need for multiline strings was not taken into account. Backticks appeared much later and thus are more versatile.
49+
Pojedyncze i podwójne cudzysłowy pochodzą ze starożytnych czasów tworzenia języka, kiedy nie brano pod uwagę potrzeby wielowierszowych ciągów. Grawisy pojawiły się znacznie później i dzięki temu są bardziej wszechstronne.
5250

53-
Backticks also allow us to specify a "template function" before the first backtick. The syntax is: <code>func&#96;string&#96;</code>. The function `func` is called automatically, receives the string and embedded expressions and can process them. This is called "tagged templates". This feature makes it easier to implement custom templating, but is rarely used in practice. You can read more about it in the [manual](mdn:/JavaScript/Reference/Template_literals#Tagged_templates).
51+
Grawisy umożliwia również określenie "funkcji szablonu" przed pierwszym grawisem. Składnia to: <code>func&#96;string&#96;</code>. Automatycznie wywoływana funkcja `func` pobiera osadzony w niej ciąg znaków i wyrażenia i może je przetwarzać. Nazywa się to „otagowanymi szablonami”. Ta funkcjonalność ułatwia implementację niestandardowych szablonów, ale jest rzadko używana w praktyce. Więcej na ten temat przeczytasz w [dokumentacji](mdn:/JavaScript/Reference/Template_literals#Tagged_templates).
5452

5553
## Special characters
5654

0 commit comments

Comments
 (0)