Skip to content

Commit aafd0d0

Browse files
authored
Translate 'Data types' page (#29)
1 parent e63610e commit aafd0d0

File tree

3 files changed

+104
-104
lines changed

3 files changed

+104
-104
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11

2-
Backticks embed the expression inside `${...}` into the string.
2+
Grawisy(backticks) dołączają wyrażenie wewnątrz `${...}` bezpośrednio do stringa.
33

44
```js run
55
let name = "Ilya";
66

7-
// the expression is a number 1
7+
// wyrażenie jest liczbą 1
88
alert( `hello ${1}` ); // hello 1
99

10-
// the expression is a string "name"
10+
// wyrażenie jest stringiem "name"
1111
alert( `hello ${"name"}` ); // hello name
1212

13-
// the expression is a variable, embed it
13+
// dołącz zmienną do stringa
1414
alert( `hello ${name}` ); // hello Ilya
1515
```

1-js/02-first-steps/05-types/1-string-quotes/task.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
importance: 5
1+
istotność: 5
22

33
---
44

5-
# String quotes
5+
# Cudzysłów w string
66

7-
What is the output of the script?
7+
Co zostanie wyświetlone przez skrypt?
88

99
```js
1010
let name = "Ilya";
+97-97
Original file line numberDiff line numberDiff line change
@@ -1,166 +1,166 @@
1-
# Data types
1+
# Typy danych
22

3-
A variable in JavaScript can contain any data. A variable can at one moment be a string and at another be a number:
3+
Zmienna w JavaScripcie może zawierać różne dane. Zmienna może być w jednej chwili łańcuchem znaków (ang. *string*), a w innym liczbą:
44

55
```js
6-
// no error
6+
// nie ma tu błędów
77
let message = "hello";
88
message = 123456;
99
```
1010

11-
Programming languages that allow such things are called "dynamically typed", meaning that there are data types, but variables are not bound to any of them.
11+
Część języków programowania stosuje tak zwane "dynamiczne typowanie", które oznacza, że typy danych zmiennych mogą zmienić się w trakcie działania programu.
1212

13-
There are seven basic data types in JavaScript. Here, we'll cover them in general and in the next chapters we'll talk about each of them in detail.
13+
Wyróżniamy 7 podstawowych typów danych w JavaScripcie. Przedstawimy je teraz ogólnie, w następnych rozdziałach omówimy bardziej szczegółowo.
1414

15-
## A number
15+
## Typ liczbowy
1616

1717
```js
1818
let n = 123;
1919
n = 12.345;
2020
```
2121

22-
The *number* type represents both integer and floating point numbers.
22+
Typ *number* reprezentuje zarówno liczby całkowite, jak i zmiennoprzecinkowe.
2323

24-
There are many operations for numbers, e.g. multiplication `*`, division `/`, addition `+`, subtraction `-`, and so on.
24+
Istnieje wiele operacji na liczbach, np. mnożenie `*`, dzielenie `/`, dodawanie `+`, odejmowanie `-` itd.
2525

26-
Besides regular numbers, there are so-called "special numeric values" which also belong to this data type: `Infinity`, `-Infinity` and `NaN`.
26+
Poza zwykłymi liczbami, wyróżniamy "specjalne wartości liczbowe", które także należą do tego typu danych: `Infinity`, `-Infinity` and `NaN`.
2727

28-
- `Infinity` represents the mathematical [Infinity](https://en.wikipedia.org/wiki/Infinity) ∞. It is a special value that's greater than any number.
28+
- `Infinity` reprezentuje w matematyce [nieskończoność](https://pl.wikipedia.org/wiki/Niesko%C5%84czono%C5%9B%C4%87) ∞. To specjalna wartość, która jest większa niż jakakolwiek inna liczba.
2929

30-
We can get it as a result of division by zero:
30+
Nieskończoność możemy uzyskać w wyniku dzielenia przez 0:
3131

3232
```js run
3333
alert( 1 / 0 ); // Infinity
3434
```
3535

36-
Or just reference it directly:
36+
Lub odwołując się do niej bezpośrednio:
3737

3838
```js run
3939
alert( Infinity ); // Infinity
4040
```
41-
- `NaN` represents a computational error. It is a result of an incorrect or an undefined mathematical operation, for instance:
41+
- `NaN` reprezentuje błąd obliczeniowy. Jest wynikiem błędnych bądź niezdefiniowanych działań matematycznych, na przykład:
4242

4343
```js run
44-
alert( "not a number" / 2 ); // NaN, such division is erroneous
44+
alert( "wartość nieliczbowa" / 2 ); // NaN, takie działanie prowadzi do błędu
4545
```
4646

47-
`NaN` is sticky. Any further operation on `NaN` returns `NaN`:
47+
Każda operacja z użyciem `NaN` zawsze zwraca `NaN` jako wynik:
4848

4949
```js run
50-
alert( "not a number" / 2 + 5 ); // NaN
50+
alert( "wartość nieliczbowa" / 2 + 5 ); // NaN
5151
```
5252

53-
So, if there's a `NaN` somewhere in a mathematical expression, it propagates to the whole result.
53+
Zatem, jeżeli `NaN` znajduje się w wyrażeniu matematycznym, staje się też jego wynikiem końcowym.
5454

55-
```smart header="Mathematical operations are safe"
56-
Doing maths is "safe" in JavaScript. We can do anything: divide by zero, treat non-numeric strings as numbers, etc.
55+
```smart header="Operacje matematyczne są bezpieczne"
56+
Przeprowadzanie obliczeń matematycznych w JavaScripcie jest "bezpieczne". Możemy dzielić przez zero, traktować ciągi znaków jako liczby itd.
5757
58-
The script will never stop with a fatal error ("die"). At worst, we'll get `NaN` as the result.
58+
Skrypt nigdy nie zatrzyma się na błędzie krytycznym. W najgorszym wypadku otrzymamy `NaN` jako wynik działania.
5959
```
6060

61-
Special numeric values formally belong to the "number" type. Of course they are not numbers in the common sense of this word.
61+
Specjalne wartości liczbowe formalnie należą do typu "liczbowego". Oczywiście nie są liczbami w definicji matematycznej.
6262

63-
We'll see more about working with numbers in the chapter <info:number>.
63+
Więcej informacji o pracy z liczbami zawarte jest w rozdziale pt. "<info:number>".
6464

65-
## A string
65+
## Typ tekstowy
6666

67-
A string in JavaScript must be surrounded by quotes.
67+
Ciąg znaków (ang. *string*), zwany także "literałem znakowym" lub "napisem", to typ tekstowy, który zapisujemy przy użyciu cudzysłowów.
6868

6969
```js
70-
let str = "Hello";
71-
let str2 = 'Single quotes are ok too';
72-
let phrase = `can embed ${str}`;
70+
let str = "Witaj";
71+
let str2 = 'Można użyć także apostrofów';
72+
let phrase = `Można dołączyć zmienną ${str}`;
7373
```
7474

75-
In JavaScript, there are 3 types of quotes.
75+
W JavaScripcie istnieją 3 typy cudzysłowów.
7676

77-
1. Double quotes: `"Hello"`.
78-
2. Single quotes: `'Hello'`.
79-
3. Backticks: <code>&#96;Hello&#96;</code>.
77+
1. Cudzysłowy: `"Witaj"`.
78+
2. Apostrofy: `'Witaj'`.
79+
3. Grawisy (ang. *backtick*): <code>&#96;Witaj&#96;</code>.
8080

81-
Double and single quotes are "simple" quotes. There's no difference between them in JavaScript.
81+
W JavaScripcie nie ma różnicy między cudzysłowami a apostrofami.
8282

83-
Backticks are "extended functionality" quotes. They allow us to embed variables and expressions into a string by wrapping them in `${…}`, for example:
83+
Grawisy są "rozszerzeniem funkcjonalności" zwykłych apostrofów i cudzysłowów. Pozwalają na dodanie zmiennej i wyrażeń do ciągu znaków poprzez umieszczenie ich wewnątrz `${}`, przykładowo:
8484

8585
```js run
86-
let name = "John";
86+
let name = "Jasiu";
8787
88-
// embed a variable
89-
alert( `Hello, *!*${name}*/!*!` ); // Hello, John!
88+
// dołączenie zmiennej
89+
alert( `Witaj, *!*${name}*/!*!` ); // Witaj, Jasiu!
9090

91-
// embed an expression
92-
alert( `the result is *!*${1 + 2}*/!*` ); // the result is 3
91+
// dołączenie wyrażenia
92+
alert( `Wynik to *!*${1 + 2}*/!*` ); // Wynik to 3
9393
```
9494

95-
The expression inside `${…}` is evaluated and the result becomes a part of the string. We can put anything in there: a variable like `name` or an arithmetical expression like `1 + 2` or something more complex.
95+
Wyrażenie wewnątrz `${…}` zostaje dołączone do części ciągu znaków. Do wyrażenia możemy wstawić cokolwiek: zmienną, na przykład `name`, lub wyrażenie arytmetyczne, jak na przykład `1 + 2`, lub coś bardziej złożonego.
9696

97-
Please note that this can only be done in backticks. Other quotes don't have this embedding functionality!
97+
Warto odnotować, że taki efekt można osiągnąć jedynie przy użyciu grawisów (``). Apostrofy i cudzysłowy nie mają takich możliwości.
9898
```js run
99-
alert( "the result is ${1 + 2}" ); // the result is ${1 + 2} (double quotes do nothing)
99+
alert( "Wynik to ${1 + 2}" ); // Wynik to ${1 + 2} (cudzysłów traktuje ${…} jako część napisu)
100100
```
101101

102-
We'll cover strings more thoroughly in the chapter <info:string>.
102+
Więcej o ciągach znaków można przeczytać w rozdziale pt. "<info:string>".
103103

104-
```smart header="There is no *character* type."
105-
In some languages, there is a special "character" type for a single character. For example, in the C language and in Java it is `char`.
104+
```smart header="JavaScript nie posiada typu *znakowego*."
105+
W niektórych językach istnieje specjalny typ "znakowy", używany do przechowywania pojedynczych znaków. Przykładowo, w językach C i Java możemy użyć typu `char`.
106106
107-
In JavaScript, there is no such type. There's only one type: `string`. A string may consist of only one character or many of them.
107+
W JavaScripcie nie ma takiego typu. Mamy do dyspozycji jedynie `string`. Ciąg znaków może być pusty albo zawierać jeden i więcej znaków.
108108
```
109109

110-
## A boolean (logical type)
110+
## Typ logiczny
111111

112-
The boolean type has only two values: `true` and `false`.
112+
Typ logiczny (ang. *boolean*) posiada dwie wartości: `true` (prawda) lub `false` (fałsz).
113113

114-
This type is commonly used to store yes/no values: `true` means "yes, correct", and `false` means "no, incorrect".
114+
Ty logiczny jest najczęsciej używany do przechowywania wartości pokroju "tak/nie", gdzie `true` to "tak, prawda", a `false` oznacza "nie, nieprawda".
115115

116-
For instance:
116+
Na przykład:
117117

118118
```js
119-
let nameFieldChecked = true; // yes, name field is checked
120-
let ageFieldChecked = false; // no, age field is not checked
119+
let nameFieldChecked = true; // tak, pole "name" jest zaznaczone (ang. *checked*)
120+
let ageFieldChecked = false; // nie, pole "age" nie jest zaznaczone
121121
```
122122

123-
Boolean values also come as a result of comparisons:
123+
Wartości typu logicznego mogą być wynikiem porównania:
124124

125125
```js run
126126
let isGreater = 4 > 1;
127127

128-
alert( isGreater ); // true (the comparison result is "yes")
128+
alert( isGreater ); // true (rezultatem porównania jest "tak" - prawda)
129129
```
130130

131-
We'll cover booleans more deeply in the chapter <info:logical-operators>.
131+
Więcej informacji o typie logicznym można znaleźć w rozdziale pt. "<info:logical-operators>".
132132

133-
## The "null" value
133+
## Wartość "null"
134134

135-
The special `null` value does not belong to any of the types described above.
135+
Wartość `null` (zwana także "literałem pustym") nie należy do żadnego z wyżej wymienionych typów danych.
136136

137-
It forms a separate type of its own which contains only the `null` value:
137+
Literał pusty posiada własny typ, którego jedyną wartością jest `null`:
138138

139139
```js
140140
let age = null;
141141
```
142142

143-
In JavaScript, `null` is not a "reference to a non-existing object" or a "null pointer" like in some other languages.
143+
W JavaScripcie `null` nie odnosi się do "nieistniejącego obiektu" lub "wskaźnika zerowego", jak ma to miejsce w innych językach programowania.
144144

145-
It's just a special value which represents "nothing", "empty" or "value unknown".
145+
Jest specjalną wartością, która reprezentuje "nic", "brak wartości" lub "nieznaną wartość".
146146

147-
The code above states that `age` is unknown or empty for some reason.
147+
Kod powyżej zakłada, że wartość zmiennej `age` jest pusta bądź nieznana z jakiegoś powodu.
148148

149-
## The "undefined" value
149+
## Wartość "undefined"
150150

151-
The special value `undefined` also stands apart. It makes a type of its own, just like `null`.
151+
Wartość `undefined` (pol. *niezdefiniowana*), podobnie jak `null`, posiada swój własny typ.
152152

153-
The meaning of `undefined` is "value is not assigned".
153+
Wartość `undefined` oznacza, że "wartość zmiennej nie jest przypisana"
154154

155-
If a variable is declared, but not assigned, then its value is `undefined`:
155+
W przypadku zadeklarowania zmiennej bez przypisania do niej konkretnej wartości, domyślna wartość to `undefined`:
156156

157157
```js run
158158
let x;
159159

160-
alert(x); // shows "undefined"
160+
alert(x); // wyświetla "undefined"
161161
```
162162

163-
Technically, it is possible to assign `undefined` to any variable:
163+
W zasadzie możliwe jest przypisanie `undefined` do zmiennej:
164164

165165
```js run
166166
let x = 123;
@@ -170,28 +170,28 @@ x = undefined;
170170
alert(x); // "undefined"
171171
```
172172

173-
...But we don't recommend doing that. Normally, we use `null` to assign an "empty" or "unknown" value to a variable, and we use `undefined` for checks like seeing if a variable has been assigned.
173+
... Jednak nie zalecamy tworzenia zmiennych o wartości `undefined`. Zazwyczaj używamy `null` dla zmiennych bez wartości, `undefined` przydaje się przy sprawdzaniu czy zmienna została przypisana do jakiejś wartości.
174174

175-
## Objects and Symbols
175+
## Obiekty i symbole
176176

177-
The `object` type is special.
177+
Typ `object` jest jedyny w swoim rodzaju.
178178

179-
All other types are called "primitive" because their values can contain only a single thing (be it a string or a number or whatever). In contrast, objects are used to store collections of data and more complex entities. We'll deal with them later in the chapter <info:object> after we learn more about primitives.
179+
Wszystkie inne typy zwane są "prostymi" (ang. *primitive*), ponieważ ich wartości mogą przechowywać tylko jedną rzecz (może to być ciąg znaków, liczba, typ logiczny itd.). W przeciwieństwie do typów prostych, obiekty używane są do przechowywania większych kolekcji danych. Więcej o obiektach omówimy poźniej w rozdziale pt. "<info:object>", po wcześniejszym omówieniu typów prostych.
180180

181-
The `symbol` type is used to create unique identifiers for objects. We mention it here for completeness, but we'll study it after objects.
181+
Typ `symbol` jest używany do tworzenia unikalnych identyfikatorów dla obiektów. Wspominamy o nim tylko dla kompletności tego rozdziału, niemniej zdecydowanie lepiej jest poznać ten typ po zrozumieniu samych obiektów.
182182

183-
## The typeof operator [#type-typeof]
183+
## Operator "typeof" [#type-typeof]
184184

185-
The `typeof` operator returns the type of the argument. It's useful when we want to process values of different types differently or just want to do a quick check.
185+
Operator `typeof` zwraca typ danego argumentu. Jest użyteczny, gdy chcemy przetworzyć wartości różnych typów lub sprawdzić sam typ.
186186

187-
It supports two forms of syntax:
187+
Występują dwa sposoby na użycie tego operatora:
188188

189-
1. As an operator: `typeof x`.
190-
2. As a function: `typeof(x)`.
189+
1. Jako operator: `typeof x`.
190+
2. Jako funkcja `typeof(x)`.
191191

192-
In other words, it works with parentheses or without them. The result is the same.
192+
Innymi słowy, bez względu na to, czy użyjemy nawiasów czy nie - wynik jest ten sam.
193193

194-
The call to `typeof x` returns a string with the type name:
194+
Wywołanie `typeof x` zwraca ciąg znaków z nazwą typu sprawdzanej zmiennej:
195195

196196
```js
197197
typeof undefined // "undefined"
@@ -200,7 +200,7 @@ typeof 0 // "number"
200200

201201
typeof true // "boolean"
202202

203-
typeof "foo" // "string"
203+
typeof "coś" // "string"
204204

205205
typeof Symbol("id") // "symbol"
206206

@@ -217,29 +217,29 @@ typeof alert // "function" (3)
217217
*/!*
218218
```
219219

220-
The last three lines may need additional explanation:
220+
Ostatnie trzy linijki wymagają dodatkowego wyjaśnienia.
221221

222-
1. `Math` is a built-in object that provides mathematical operations. We will learn it in the chapter <info:number>. Here, it serves just as an example of an object.
223-
2. The result of `typeof null` is `"object"`. That's wrong. It is an officially recognized error in `typeof`, kept for compatibility. Of course, `null` is not an object. It is a special value with a separate type of its own. So, again, this is an error in the language.
224-
3. The result of `typeof alert` is `"function"`, because `alert` is a function. We'll study functions in the next chapters where we'll also see that there's no special "function" type in JavaScript. Functions belong to the object type. But `typeof` treats them differently, returning `"function"`. That's not quite correct, but very convenient in practice.
222+
1. `Math` jest wbudowanym obiektem, który daje dostęp do operacji matematycznych. Dowiemy się o nim więcej w rozdziale pt. "<info:number>". W tym przypadku posłużył jako przykład obiektu.
223+
2. Wynikiem wywołania `typeof null` jest `object`. Jest to znany błąd związany z `typeof`, nie został on jednak poprawiony ze względu na wsteczną kompatybilność. Oczywiście `null` nie jest obiektem - posiada własny typ.
224+
3. Wynikiem wywołania `typeof alert` jest `"function"` ze względu na to, że `alert` jest po prostu funkcją. O funkcjach napisaliśmy więcej w następnych rozdziałach, gdzie zauważamy, że tak naprawdę nie ma typu "function" w JavaScripcie. Funkcje należą do typu "object". Jednak `typeof` traktuje funkcje inaczej, zwracając `"function"`, co nie jest do końca poprawne, lecz bardzo wygodne w praktyce.
225225

226226

227-
## Summary
227+
## Podsumowanie
228228

229-
There are 7 basic data types in JavaScript.
229+
W JavaScripcie wyróżniamy 7 podstawowych typów danych.
230230

231-
- `number` for numbers of any kind: integer or floating-point.
232-
- `string` for strings. A string may have one or more characters, there's no separate single-character type.
233-
- `boolean` for `true`/`false`.
234-
- `null` for unknown values -- a standalone type that has a single value `null`.
235-
- `undefined` for unassigned values -- a standalone type that has a single value `undefined`.
236-
- `object` for more complex data structures.
237-
- `symbol` for unique identifiers.
231+
- `number` dla wszystkich liczb: całkowitych lub zmiennoprzecinkowych.
232+
- `string` dla ciągów znaków. Może być pusty albo zawierać jeden czy więcej znaków; nie ma oddzielnego typu dla pojedynczego znaku.
233+
- `boolean` dla `true`/`false` (prawda/fałsz).
234+
- `null` dla pustych wartości -- autonomiczny typ, który posiada jedną wartość: `null`.
235+
- `undefined` dla niezdefiniowanych wartości -- autonomiczny typ, który posiada jedną wartość: `undefined`.
236+
- `object` dla bardziej złożonych struktur danych.
237+
- `symbol` dla unikalnych identyfikatorów.
238238

239-
The `typeof` operator allows us to see which type is stored in a variable.
239+
Operator `typeof` pozwala na sprawdzenie typu zmiennej.
240240

241-
- Two forms: `typeof x` or `typeof(x)`.
242-
- Returns a string with the name of the type, like `"string"`.
243-
- For `null` returns `"object"` -- this is an error in the language, it's not actually an object.
241+
- Istnieją dwie formy: `typeof x` lub `typeof(x)`.
242+
- Zwraca ciąg znaków z nazwą danego typu, na przykład `"string"`.
243+
- Dla wartości `null` zwraca `"object"` -- jest to błąd w JavaScripcie, ponieważ `null` nie jest typu "object".
244244

245-
In the next chapters, we'll concentrate on primitive values and once we're familiar with them, we'll move on to objects.
245+
W następnych rozdziałach skupimy się na typach prostych, a gdy już będziemy z nimi zaznajomieni, poznamy obiekty.

0 commit comments

Comments
 (0)