You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 1-js/02-first-steps/05-types/article.md
+40-40Lines changed: 40 additions & 40 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,7 +25,7 @@ Netrūksta veiksmų skaičiams, kaip pavyzdžiui daugyba `*`, dalyba `/`, sudėt
25
25
26
26
Kartu su įprastiniais skaičiais, yra taip vadinamos "specialios skaitinės reikšmės", kurios taip pat priklauso šiam duomenų tipui: `Infinity`, `-Infinity` ir `NaN`.
27
27
28
-
-`Infinity` atstovauja matematinę [Begalybę](https://en.wikipedia.org/wiki/Infinity) ∞. Tai speciali reikšmė, kuri yra didesnė nei bet koks skaičius.
28
+
-`Infinity` atstovauja matematinę [begalybę](https://en.wikipedia.org/wiki/Infinity) ∞. Tai speciali reikšmė, kuri yra didesnė nei bet koks skaičius.
29
29
30
30
Ją gauname kaip rezultatą kai daliname iš nulio:
31
31
@@ -38,7 +38,7 @@ Kartu su įprastiniais skaičiais, yra taip vadinamos "specialios skaitinės rei
38
38
```js run
39
39
alert( Infinity ); // Infinity
40
40
```
41
-
-`NaN` atstovauja skaičiavimo klaidą. Tai yra neteisingo ar neapibrėžto (ang. undefined) mateminio veiksmo rezultatas, pavyzdžiui:
41
+
-`NaN` atstovauja skaičiavimo klaidą. Tai yra neteisingo ar neapibrėžto (ang. undefined) matematinio veiksmo rezultatas, pavyzdžiui:
42
42
43
43
```js run
44
44
alert( "ne skaičius" / 2 ); // NaN, tokia dalyba yra klaidinga
alert( `rezultas yra *!*${1+2}*/!*` ); // rezultatas yra 3
93
93
```
94
94
95
-
Išraiška viduje `${…}` yra įvertinama ir rezultatas tampa eilutės dalimi. Mes galime įdėti bet ką: tokį kintamąjį kaip `name` arba aritmetinę išraišką kaip `1 + 2` arba ką nors dar sudėtingesnio.
95
+
Išraiška viduje `${…}` yra įvertinama ir rezultatas tampa eilutės dalimi. Mes galime įterpti bet ką: tokį kintamąjį kaip `name` arba aritmetinę išraišką kaip `1 + 2` arba ką nors dar sudėtingesnio.
96
96
97
97
Atkreipkite dėmesį, kad tai galima padaryti tik su atvirkštinėmis kabutėmis. Kitos kabutės neturi tokio įterpimo funkcionalumo!
98
98
```js run
@@ -140,27 +140,27 @@ Jis formuoja atskirą savo tipą, kuriame yra tik `null` vertė:
140
140
let age =null;
141
141
```
142
142
143
-
JavaScript `null` nėra "nuoroda į neegzistuojantį objektą" arba į "nulinę užuomeną" (ang. "null pointer") kaip kai kurios kitos kalbos.
143
+
JavaScript `null` nėra "nuoroda į neegzistuojantį objektą" arba į "nulinę užuomeną" (ang. "null pointer") kaip kai kuriose kitose kalbose.
144
144
145
145
Tai tik speciali vertė, kuri atstovauja "nieką", "tuštumą" arba "vertė nežinoma".
146
146
147
147
Kodas viršuje reiškia, kad `age` nėra žinomas arba tuščias dėl neaiškios priežasties.
148
148
149
-
## The "undefined" value
149
+
## Vertė "undefined"
150
150
151
-
The special value `undefined`also stands apart. It makes a type of its own, just like`null`.
151
+
Ypatingoji vertė `undefined`(neapibrėžtas) taip pat yra išskirtinė, nes turi savo pačios tipą kaip ir`null`.
152
152
153
-
The meaning of `undefined`is "value is not assigned".
153
+
`undefined`reškia, kad "vertė nėra priskirta".
154
154
155
-
If a variable is declared, but not assigned, then its value is`undefined`:
155
+
Jeigu kintamasis deklaruotas, bet nepriskirtas, tada jo vertė yra`undefined`:
156
156
157
157
```js run
158
158
let x;
159
159
160
-
alert(x); //shows "undefined"
160
+
alert(x); //parodo "undefined"
161
161
```
162
162
163
-
Technically, it is possible to assign `undefined`to any variable:
163
+
Techniškai yra įmanoma priskirti `undefined`vertę bet kuriam kintamajam:
164
164
165
165
```js run
166
166
let x =123;
@@ -170,28 +170,28 @@ x = undefined;
170
170
alert(x); // "undefined"
171
171
```
172
172
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
+
...Bet mes nerekomenduojame to daryti. Dažniausiai tam, kad priskirtume "tuščią" ar "nežinomą" vertę kintamajam, mes naudojame `null`, o `undefined`naudojame patikrinimams ar kintamajam buvo priskirta vertė.
174
174
175
-
## Objects and Symbols
175
+
## Objektai ir Simboliai
176
176
177
-
The`object`type is special.
177
+
Objekto`object`tipas yra ypatingas.
178
178
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
+
Visi kiti tipai vadinami "primityviais", nes jų vertė gali turėti tik vieną dalyką (nesvarbu ar tai eilutė, numeris ar kita). Tuo tarpu objektai naudojami saugoti duomenų kolekcijas ir daug sudėtingesnius darinius. Apie juos kalbėsime vėliau skyriuje <info:object>kai sužinosime daugiau apie primityvius tipus.
180
180
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
+
Simbolio`symbol`tipas yra skirtas sukurti unikalius identifikatorius skirtus objektams. Paminėjome juos tik dėl užbaigtumo, bet labiau juos studijuosime po objektų.
182
182
183
-
## The typeof operator[#type-typeof]
183
+
## Operatorius typeof [#type-typeof]
184
184
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
+
Operatorius`typeof`grąžina argumento tipą. Jis naudingas kai mes norime išskirtinai apdoroti skirtingų tipų vertes arba norime greitai patikrinti tipą.
186
186
187
-
It supports two forms of syntax:
187
+
Jis palaiko dviejų formų sintaksę:
188
188
189
-
1.As an operator: `typeof x`.
190
-
2.As a function: `typeof(x)`.
189
+
1.Kaip operatorius: `typeof x`.
190
+
2.Kaip funkcija: `typeof(x)`.
191
191
192
-
In other words, it works with parentheses or without them. The result is the same.
192
+
Kitais žodžiais, jis veikia su skliausteliais ar be jų. Rezultatas toks pats.
193
193
194
-
The call to `typeof x`returns a string with the type name:
194
+
Šaukimas `typeof x`grąžina eilutę su tipo pavadinimu:
The last three lines may need additional explanation:
220
+
Paskutinės trys eilės gali reikalauti papildomo paaiškinimo:
221
221
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`yra įrašyta (ang. "built-in") matematinė operacija. Apie ją sužinosime skyriuje <info:number>. Čia ji yra tik kaip objekto pavyzdys.
223
+
2.Rezultatas iš `typeof null`yra`"object"`. Tai nėra tiesa. Tai yra oficialiai pripažinta `typeof` klaida, palikta dėl suderinamumo. Žinoma, kad `null`nėra objektas. Tai yra ypatinga vertė su atskiru tipu. Tad dar kartą, tai yra kalbos klaida.
224
+
3.Rezultatas iš `typeof alert`yra`"function"`, nes`alert`ir yra funkcija. Funkcijas studijuosime sekančiuose skyriuose kur sužinosime, kad JavaScript neturi atskiro ypatingo "funkcijos" tipo. Funkcijos priklauso prie objekto tipo. Bet`typeof`jas vertina kitaip, grąžindamas`"function"`. Tai nėra visiška teisinga, bet praktiškai labai patogu.
225
225
226
226
227
-
## Summary
227
+
## Santrauka
228
228
229
-
There are 7 basic data types in JavaScript.
229
+
JavaScript turi 7 pagrindinius duomenų tipus.
230
230
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`skirta bet kokio tipo skaičiams: sveikiems ir slankiojančio kablelio skaičiams.
232
+
-`string`skirta eilutėms. Eilutė gali turi vieną ar daugiau ženklų, nėra atskiro vieno-ženklo tipo.
233
+
-`boolean`skirta`true`/`false`.
234
+
-`null`skirta nežinomoms vertėms -- atskiras tipas turinti tik vieną vertę`null`.
235
+
-`undefined`nepriskirtoms vertėms -- atskiras tipas turinti vieną vertę`undefined`.
236
+
-`object`skirta sudėtingesnėms duomenų struktūroms.
237
+
-`symbol`skirta unikaliems identifikatoriams.
238
238
239
-
The`typeof`operator allows us to see which type is stored in a variable.
239
+
Operatorius`typeof`leidžia matyti, kuris tipas yra saugomas kintamajame.
240
240
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
+
-Dvi formos: `typeof x`arba`typeof(x)`.
242
+
-Grąžina eilutę su tipo pavadinimu kaip pavyzdžiui`"string"`.
243
+
-Kai yra `null`grąžina`"object"` -- klaida kalboje, nes tai iš tikrųjų nėra objektas.
244
244
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
+
Kituose skyriuose susikoncentruosime prie primityvių verčių, o kai su jomis būsime pažįstami, pereisime prie objektų.
0 commit comments