Skip to content

Commit bef78ac

Browse files
authored
Merge pull request #69 from meilune/master
Translated Data Type section
2 parents 402c6ae + 30b0d42 commit bef78ac

File tree

3 files changed

+108
-108
lines changed

3 files changed

+108
-108
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+
Atvirkštinės kabutės įterpia išraišką esančią viduje `${...}` į pačią eilutę.
33

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

7-
// the expression is a number 1
8-
alert( `hello ${1}` ); // hello 1
7+
// išraiška yra skaičius 1
8+
alert( `labas ${1}` ); // labas 1
99

10-
// the expression is a string "name"
11-
alert( `hello ${"name"}` ); // hello name
10+
// išraiška yra eilutė "name"
11+
alert( `labas ${"name"}` ); // labas name
1212

13-
// the expression is a variable, embed it
14-
alert( `hello ${name}` ); // hello Ilya
13+
// išraiška yra kintamasis, jo vertė įterpiama
14+
alert( `labas ${name}` ); // labas Ilya
1515
```

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@ importance: 5
22

33
---
44

5-
# String quotes
5+
# Eilučių kabutės
66

7-
What is the output of the script?
7+
Kokį gausime skripto rezultatą?
88

99
```js
1010
let name = "Ilya";
1111

12-
alert( `hello ${1}` ); // ?
12+
alert( `labas ${1}` ); // ?
1313

14-
alert( `hello ${"name"}` ); // ?
14+
alert( `labas ${"name"}` ); // ?
1515

16-
alert( `hello ${name}` ); // ?
17-
```
16+
alert( `labas ${name}` ); // ?
17+
```
+95-95
Original file line numberDiff line numberDiff line change
@@ -1,166 +1,166 @@
1-
# Data types
1+
# Duomenų tipai
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+
Kintamasis JavaScript gali savyje laikyti bet kokius duomenis. Kintamasis gali vienu momentu būti eilutė, o kitu numeris:
44

55
```js
66
// no error
7-
let message = "hello";
7+
let message = "labas";
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+
Programinės kalbos, kurios tai leidžia yra vadinamos "dinamiškai tipizuotomis" (ang. "dynamically typed"), tai reiškia, kad duomenų tipai yra, tačiau kintamieji nėra prie jų pririšti.
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+
JavaScript turi septynis pagrindinius duomenų tipus. Čia mes juos peržvelgsime bendrai, o tolesniuose skyriuose apie kiekvieną pakalbėsime detaliau.
1414

15-
## A number
15+
## Skaičius
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+
*Skaičiaus* tipas atstovauja sveikus skaičius (ang. integer) ir slankiojo kablelio skaičius (ang. floating point numbers).
2323

24-
There are many operations for numbers, e.g. multiplication `*`, division `/`, addition `+`, subtraction `-`, and so on.
24+
Netrūksta veiksmų skaičiams, kaip pavyzdžiui daugyba `*`, dalyba `/`, sudėtis `+`, atimtis `-`, ir taip toliau.
2525

26-
Besides regular numbers, there are so-called "special numeric values" which also belong to this data type: `Infinity`, `-Infinity` and `NaN`.
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`.
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` atstovauja matematinę [begalybę](https://en.wikipedia.org/wiki/Infinity) ∞. Tai speciali reikšmė, kuri yra didesnė nei bet koks skaičius.
2929

30-
We can get it as a result of division by zero:
30+
Ją gauname kaip rezultatą kai daliname iš nulio:
3131

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

36-
Or just reference it directly:
36+
Arba kai tiesiogiai nurodome:
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` atstovauja skaičiavimo klaidą. Tai yra neteisingo ar neapibrėžto (ang. undefined) matematinio veiksmo rezultatas, pavyzdžiui:
4242

4343
```js run
44-
alert( "not a number" / 2 ); // NaN, such division is erroneous
44+
alert( "ne skaičius" / 2 ); // NaN, tokia dalyba yra klaidinga
4545
```
4646

47-
`NaN` is sticky. Any further operation on `NaN` returns `NaN`:
47+
`NaN` yra kabus. Bet kokie tolesni veiksmai su `NaN` grąžins `NaN`:
4848

4949
```js run
50-
alert( "not a number" / 2 + 5 ); // NaN
50+
alert( "ne skaičius" / 2 + 5 ); // NaN
5151
```
5252

53-
So, if there's a `NaN` somewhere in a mathematical expression, it propagates to the whole result.
53+
Taigi, jeigu kažkur matematinėje formulėje yra `NaN` jis persiduoda į visus tolesnius rezultatus.
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="Matematiniai veiksmai yra saugūs"
56+
Užsiimti matematika JavaScript yra "saugu". Galime daryti viską: dalinti iš nulio, elgtis su neskaitinėmis eilutėmis kaip su skaičiais ir t.t.
5757
58-
The script will never stop with a fatal error ("die"). At worst, we'll get `NaN` as the result.
58+
Skriptas niekada nesustos dėl lemtingos klaidos ("mirs"). Blogiausia kas gali būti, mes gausime `NaN` kaip rezultatą.
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+
Specialios skaitinės reikšmės priklauso "skaičių" tipui. Žinoma, jie nėra skaičiai įprastine šio žodžio reikšme.
6262

63-
We'll see more about working with numbers in the chapter <info:number>.
63+
Daugiau apie darbą su skaičiais bus skyriuje <info:number>.
6464

65-
## A string
65+
## Eilutė
6666

67-
A string in JavaScript must be surrounded by quotes.
67+
Eilutė JavaScript turi būti apsupta kabutėmis.
6868

6969
```js
70-
let str = "Hello";
71-
let str2 = 'Single quotes are ok too';
72-
let phrase = `can embed ${str}`;
70+
let str = "Labas";
71+
let str2 = 'Viengubos kabutės taip pat tinka';
72+
let phrase = `galima įterpti ${str}`;
7373
```
7474

75-
In JavaScript, there are 3 types of quotes.
75+
JavaScript turi 3-ų tipų kabutes.
7676

77-
1. Double quotes: `"Hello"`.
78-
2. Single quotes: `'Hello'`.
79-
3. Backticks: <code>&#96;Hello&#96;</code>.
77+
1. Dvigubos kabutės: `"Hello"`.
78+
2. Viengubos kabutės: `'Hello'`.
79+
3. Atvirkštinės kabutės: <code>&#96;Labas&#96;</code>.
8080

81-
Double and single quotes are "simple" quotes. There's no difference between them in JavaScript.
81+
Dvigubos ir viengubos kabutės yra "paprastosios" kabutės. Tarp jų nėra jokio skirtumo JavaScript.
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+
Atvirkštinės kabutės yra kabutės su "išplėstu funkcionalumu". Jos leidžia mums įterpti kintamuosius ir išraiškas į pačią eilutę kai apsupame juos tokiais ženklais `${}`, pavyzdžiui:
8484

8585
```js run
8686
let name = "John";
8787
88-
// embed a variable
89-
alert( `Hello, *!*${name}*/!*!` ); // Hello, John!
88+
// įterpti kintamąjį
89+
alert( `Labas, *!*${name}*/!*!` ); // Labas, John!
9090

91-
// embed an expression
92-
alert( `the result is *!*${1 + 2}*/!*` ); // the result is 3
91+
// įterpti išraišką
92+
alert( `rezultas yra *!*${1 + 2}*/!*` ); // rezultatas yra 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+
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.
9696

97-
Please note that this can only be done in backticks. Other quotes don't have this embedding functionality!
97+
Atkreipkite dėmesį, kad tai galima padaryti tik su atvirkštinėmis kabutėmis. Kitos kabutės neturi tokio įterpimo funkcionalumo!
9898
```js run
99-
alert( "the result is ${1 + 2}" ); // the result is ${1 + 2} (double quotes do nothing)
99+
alert( "rezultatas yra ${1 + 2}" ); // rezultatas yra ${1 + 2} (dvigubos kabutės nieko nepadaro)
100100
```
101101

102-
We'll cover strings more thoroughly in the chapter <info:string>.
102+
Mes kalbėsime daugiau apie eilutes skyriuje <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="Nėra tokio tipo kaip *ženklas*."
105+
Kai kuriose kalbose yra specialus "ženklo" (ang. character) tipas skirtas vienetiniam ženklui. Pavyzdžiui tokiose kalbose kaip C arba Java toks ženklas yra vadinamas `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+
JavaScript tokio tipo nėra. Yra tik vienas tipas: `string`(eilutė). Eilutė gali būti sudaryta iš vieno ženklo arba iš daug ženklų.
108108
```
109109

110-
## A boolean (logical type)
110+
## Loginis tipas
111111

112-
The boolean type has only two values: `true` and `false`.
112+
Loginis tipas (ang. boolean) turi tik dvi reikšmes: `true` (tiesa) ir `false`(netiesa).
113113

114-
This type is commonly used to store yes/no values: `true` means "yes, correct", and `false` means "no, incorrect".
114+
Šis tipas dažniausiai naudojamas, kad išsaugotų taip/ne vertes: `true` reiškia "taip, teisingai", o `false` reiškia "ne, netesingai".
115115

116-
For instance:
116+
Pavyzdžiui:
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; // taip, vardo laukelis pažymėtas
120+
let ageFieldChecked = false; // ne, amžiaus laukelis nepažymėtas
121121
```
122122

123-
Boolean values also come as a result of comparisons:
123+
Loginės vertės taip pat yra palyginimų rezultatas:
124124

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

128-
alert( isGreater ); // true (the comparison result is "yes")
128+
alert( isGreater ); // tiesa (palyginimo rezultatas yra "taip")
129129
```
130130

131-
We'll cover booleans more deeply in the chapter <info:logical-operators>.
131+
Mes daugiau kalbėsime apie loginį tipą skyriuje <info:logical-operators>.
132132

133-
## The "null" value
133+
## "null" vertė
134134

135-
The special `null` value does not belong to any of the types described above.
135+
Ypatingoji `null` (negaliojanti) vertė nepriklauso jokiam anksčiau minėtam tipui.
136136

137-
It forms a separate type of its own which contains only the `null` value:
137+
Jis formuoja atskirą savo tipą, kuriame yra tik `null` vertė:
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+
JavaScript `null` nėra "nuoroda į neegzistuojantį objektą" arba į "nulinę užuomeną" (ang. "null pointer") kaip kai kuriose kitose kalbose.
144144

145-
It's just a special value which represents "nothing", "empty" or "value unknown".
145+
Tai tik speciali vertė, kuri atstovauja "nieką", "tuštumą" arba "vertė nežinoma".
146146

147-
The code above states that `age` is unknown or empty for some reason.
147+
Kodas viršuje reiškia, kad `age` nėra žinomas arba tuščias dėl neaiškios priežasties.
148148

149-
## The "undefined" value
149+
## Vertė "undefined"
150150

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`.
152152

153-
The meaning of `undefined` is "value is not assigned".
153+
`undefined` reškia, kad "vertė nėra priskirta".
154154

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`:
156156

157157
```js run
158158
let x;
159159

160-
alert(x); // shows "undefined"
160+
alert(x); // parodo "undefined"
161161
```
162162

163-
Technically, it is possible to assign `undefined` to any variable:
163+
Techniškai yra įmanoma priskirti `undefined` vertę bet kuriam kintamajam:
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+
...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ė.
174174

175-
## Objects and Symbols
175+
## Objektai ir Simboliai
176176

177-
The `object` type is special.
177+
Objekto `object` tipas yra ypatingas.
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+
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.
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+
Simbolio `symbol` tipas yra skirtas sukurti unikalius identifikatorius skirtus objektams. Paminėjome juos tik dėl užbaigtumo, bet labiau juos studijuosime po objektų.
182182

183-
## The typeof operator [#type-typeof]
183+
## Operatorius 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+
Operatorius `typeof` grąžina argumento tipą. Jis naudingas kai mes norime išskirtinai apdoroti skirtingų tipų vertes arba norime greitai patikrinti tipą.
186186

187-
It supports two forms of syntax:
187+
Jis palaiko dviejų formų sintaksę:
188188

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)`.
191191

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.
193193

194-
The call to `typeof x` returns a string with the type name:
194+
Šaukimas `typeof x` grąžina eilutę su tipo pavadinimu:
195195

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

220-
The last three lines may need additional explanation:
220+
Paskutinės trys eilės gali reikalauti papildomo paaiškinimo:
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` 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škai teisinga, bet praktiškai labai patogu.
225225

226226

227-
## Summary
227+
## Santrauka
228228

229-
There are 7 basic data types in JavaScript.
229+
JavaScript turi 7 pagrindinius duomenų tipus.
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` skirta bet kokio tipo skaičiams: sveikiems ir slankiojančio kablelio skaičiams.
232+
- `string` skirta eilutėms. Eilutė gali turėti vieną ar daugiau ženklų, nėra atskiro vieno-ženklo tipo.
233+
- `boolean` skirta `true`/`false`.
234+
- `null` skirta nežinomoms vertėms -- atskiras tipas turintis tik vieną vertę `null`.
235+
- `undefined` nepriskirtoms vertėms -- atskiras tipas turintis vieną vertę `undefined`.
236+
- `object` skirta sudėtingesnėms duomenų struktūroms.
237+
- `symbol` skirta unikaliems identifikatoriams.
238238

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.
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+
- 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.
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+
Kituose skyriuose susikoncentruosime prie primityvių verčių, o kai su jomis būsime pažįstami, pereisime prie objektų.

0 commit comments

Comments
 (0)