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/04-variables/article.md
+51-51
Original file line number
Diff line number
Diff line change
@@ -8,158 +8,158 @@ Kintamieji yra naudojami tam, kad kauptų šią informaciją.
8
8
9
9
## Kintamasis
10
10
11
-
[Kintamasis](https://en.wikipedia.org/wiki/Variable_(computer_science)) yra "is a "named storage" for data. We can use variables to store goodies, visitors, and other data.
11
+
[Kintamasis](https://en.wikipedia.org/wiki/Variable_(computer_science)) yra "įvardinta saugykla" duomenims. Mes galime naudoti kintamuosius, kad kauptume gėrybes, lankytojus ir kitus duomenis.
12
12
13
-
To create a variable in JavaScript, use the `let` keyword.
13
+
Norėdami sukurti kintamąjį su JavaScript, naudokite `let`raktinį žodį (ang. "keyword").
14
14
15
-
The statement below creates (in other words: *declares*) a variable with the name "message":
15
+
Žemiau esantis pareiškimas sukuria (kitais žodžiais: *declaruoja* ang.*declares*) kintamąjį su pavadinimu "message":
16
16
17
17
```js
18
18
let message;
19
19
```
20
20
21
-
Now, we can put some data into it by using the assignment operator`=`:
21
+
Dabar į jį galime patalpinti duomenis naudodami užduoties operatorių`=`:
22
22
23
23
```js
24
24
let message;
25
25
26
26
*!*
27
-
message ='Hello'; //store the string
27
+
message ='Labas'; //patalpinama eilutė
28
28
*/!*
29
29
```
30
30
31
-
The string is now saved into the memory area associated with the variable. We can access it using the variable name:
31
+
Dabar eilutė yra išsaugota į atminties sritį susijusią su kintamuoju. Mes galime gauti prieigą naudodami kintamojo pavadinimą.
32
32
33
33
```js run
34
34
let message;
35
-
message ='Hello!';
35
+
message ='Labas!';
36
36
37
37
*!*
38
-
alert(message); //shows the variable content
38
+
alert(message); //parodo kintamojo turinį
39
39
*/!*
40
40
```
41
41
42
-
To be concise, we can combine the variable declaration and assignment into a single line:
42
+
Dėl glaustumo galime sujungti kintamojo deklaraciją ir užduotį į vieną eilę:
43
43
44
44
```js run
45
-
let message ='Hello!'; //define the variable and assign the value
45
+
let message ='Labas!'; //apibrėžti kintamąjį ir priskirti jam vertę
46
46
47
-
alert(message); //Hello!
47
+
alert(message); //Labas!
48
48
```
49
49
50
-
We can also declare multiple variables in one line:
50
+
Mes taip pat galime deklaruoti kelis kintamuosius vienoje eilėje:
51
51
52
52
```js no-beautify
53
-
let user ='John', age =25, message ='Hello';
53
+
let user ='John', age =25, message ='Labas';
54
54
```
55
55
56
-
That might seem shorter, but we don't recommend it. For the sake of better readability, please use a single line per variable.
56
+
Tai atrodo trumpiau, bet iš tikrųjų mes nerekomenduojame taip daryti. Tam, kad būtų lengviau perskaityti kodą, prašau, naudokite vieną eilę kiekvienam kintamajam.
57
57
58
-
The multiline variant is a bit longer, but easier to read:
58
+
Kelių eilučių variantas ilgesnis, bet jį lengviau perskaityti:
59
59
60
60
```js
61
61
let user ='John';
62
62
let age =25;
63
-
let message ='Hello';
63
+
let message ='Labas';
64
64
```
65
65
66
-
Some people also define multiple variables in this multiline style:
66
+
Kai kurie žmonės apibrėžia kelis kintamuosius tokiu kelių eilių stiliumi:
67
67
```js no-beautify
68
68
let user ='John',
69
69
age =25,
70
-
message ='Hello';
70
+
message ='Labas';
71
71
```
72
72
73
-
...Or even in the "comma-first" style:
73
+
...Arba netgi "kablelis priekyje" stiliumi:
74
74
75
75
```js no-beautify
76
76
let user ='John'
77
77
, age =25
78
-
, message ='Hello';
78
+
, message ='Labas';
79
79
```
80
80
81
-
Technically, all these variants do the same thing. So, it's a matter of personal taste and aesthetics.
81
+
Techniškai, visi šie variantai daro tą patį. Tad tai daugiau asmeninio skonio ir estetikos reikalas.
82
82
83
83
84
-
````smart header="`var`instead of`let`"
85
-
In older scripts, you may also find another keyword: `var`instead of`let`:
84
+
````smart header="`var`vietoje`let`"
85
+
Senesniuose skriptuose galite rasti raktažodį: `var`vietoje`let`:
86
86
87
87
```js
88
-
*!*var*/!* message ='Hello';
88
+
*!*var*/!* message ='Labas';
89
89
```
90
90
91
-
The`var`keyword is *almost* the same as`let`. It also declares a variable, but in a slightly different, "old-school" way.
91
+
Raktažodis`var`yra *beveik* tas pats kaip`let`. Jis taip pat deklaruoja kintamąjį, bet šiekt eik kitokiu, "senoviniu" būdu.
92
92
93
-
There are subtle differences between `let`and`var`, but they do not matter for us yet. We'll cover them in detail in the chapter<info:var>.
93
+
Yra subtilūs skirtumai tarp `let`ir`var`, bet kol kas jie mums nėra svarbūs. Mes apie juos kalbėsime detaliau skyriuje<info:var>.
94
94
````
95
95
96
-
## A real-life analogy
96
+
## Tikro gyvenimo analogija
97
97
98
-
We can easily grasp the concept of a "variable" if we imagine it as a "box" for data, with a uniquely-named sticker on it.
98
+
Mes galime lengviau suprasti "kintamojo" sąvoką jeigu įsivaizduotume jį kaip "dėžę" skirtą duomenims ant kurios priklijuotas unikaliai pavadintas lipdukas.
99
99
100
-
For instance, the variable `message` can be imagined as a box labeled `"message"` with the value `"Hello!"` in it:
100
+
Pavyzdžiui kintamąjį `message` galime įsivaizduoti kaip dėžę su etikete `"message"`, kurios viduje yra patalpinta vertė `"Labas!"`:
101
101
102
102

103
103
104
-
We can put any value in the box.
104
+
Mes galime į dėžę įdėti bet kokią vertę.
105
105
106
-
We can also change it as many times as we want:
106
+
Mes taip pat galime ją pakeisti kiek norime kartų:
107
107
```js run
108
108
let message;
109
109
110
-
message = 'Hello!';
110
+
message = 'Labas!';
111
111
112
-
message = 'World!'; // value changed
112
+
message = 'Pasauli!'; // vertė pakeista
113
113
114
114
alert(message);
115
115
```
116
116
117
-
When the value is changed, the old data is removed from the variable:
117
+
Kai vertė yra pakeičiama, seni duomenys panaikinami iš kintamojo:
118
118
119
119

120
120
121
-
We can also declare two variables and copy data from one into the other.
121
+
Mes taip pat galime deklaruoti du kintamuosius ir nukopijuoti duomenis iš vieno į kitą.
122
122
123
123
```js run
124
-
let hello = 'Hello world!';
124
+
let hello = 'Labas pasauli!';
125
125
126
126
let message;
127
127
128
128
*!*
129
-
// copy 'Hello world' from hello into message
129
+
// nukopijuoti 'Labas pasauli' iš hello į message
130
130
message = hello;
131
131
*/!*
132
132
133
-
// now two variables hold the same data
134
-
alert(hello); // Hello world!
135
-
alert(message); // Hello world!
133
+
// dabar abu kintamieji savyje laiko tuos pačius duomenis
134
+
alert(hello); // Labas pasauli!
135
+
alert(message); // Labas pasauli!
136
136
```
137
137
138
-
```smart header="Functional languages"
139
-
It's interesting to note that there exist [functional](https://en.wikipedia.org/wiki/Functional_programming) programming languages, like [Scala](http://www.scala-lang.org/) or [Erlang](http://www.erlang.org/) that forbid changing variable values.
138
+
```smart header="Funkcinės kalbos"
139
+
Yra įdomu pastebėti, kad egzistuoja [funkcinės](https://en.wikipedia.org/wiki/Functional_programming) programavimo kalbos, tokios kaip [Scala](http://www.scala-lang.org/) arba [Erlang](http://www.erlang.org/), kurios draudžia keisti kintamųjų vertes.
140
140
141
-
In such languages, once the value is stored "in the box", it's there forever. If we need to store something else, the language forces us to create a new box (declare a new variable). We can't reuse the old one.
141
+
Tokiose kalbose, kai vertė yra patalpinama "į dėžę", ji ten ir pasilieka amžiams. Jeigu norime patalpinti kažką kito, kalba mus priverčia sukurti naują dėžę (deklaruoti naują kintamąjį). Mes nebegalime dar kartą panaudoti senojo.
142
142
143
-
Though it may seem a little odd at first sight, these languages are quite capable of serious development. More than that, there are areas like parallel computations where this limitation confers certain benefits. Studying such a language (even if you're not planning to use it soon) is recommended to broaden the mind.
143
+
Nors tai atrodo keistai iš pirmo žvilgsnio, tačiau šios kalbos yra gana gabios rimtame programų kūrime. Dar daugiau, yra tam tikrų sričių kaip lygiagretusis skaičiavimas (ang. "parallel computations") kur toks apribojimas suteikia tam tikros naudos. Studijuoti tokią kalbą (net jeigu neplanuojate jos greitu laiku naudoti) yra rekomenduotina, kad praplėstumėte savo mąstymą.
144
144
```
145
145
146
-
## Variable naming [#variable-naming]
146
+
## Kintamųjų įvardinimas [#variable-naming]
147
147
148
-
There are two limitations on variable names in JavaScript:
148
+
Yra du apribojimai kintamųjų pavadinimams JavaScript:
149
149
150
-
1. The name must contain only letters, digits, or the symbols `$` and `_`.
151
-
2. The first character must not be a digit.
150
+
1. Pavadinimas gali būti sudarytas tik iš raidžių, skaitmenų arba simbolių `$` ir `_`.
151
+
2. Pirmas ženklas negali būti skaičius.
152
152
153
-
Examples of valid names:
153
+
Tinkamų pavadinimų pavyzdžiai:
154
154
155
155
```js
156
156
let userName;
157
157
let test123;
158
158
```
159
159
160
-
When the name contains multiple words, [camelCase](https://en.wikipedia.org/wiki/CamelCase) is commonly used. That is: words go one after another, each word except first starting with a capital letter: `myVeryLongName`.
160
+
Kai pavadinimas susideda iš kelių žodžių, dažniausiai naudojamas [camelCase](https://en.wikipedia.org/wiki/CamelCase) (tiesioginis vertimas - kupranugario atvejis). Tai reiškia: žodžiai seka vienas kitą, kiekvienas žodis išskyrus pirmąjį prasideda iš didžiosios raidės: `manoLabaiIlgasVardas`.
161
161
162
-
What's interesting -- the dollar sign `'$'` and the underscore `'_'` can also be used in names. They are regular symbols, just like letters, without any special meaning.
162
+
Įdomu -- dolerio `'$'` ir pabrėžimo `'_'` ženklai gali būti naudojami pavadinimuose. Jie yra normalūs simboliai, taip pat kaip raidės, be jokios ypatingos reikšmės.
0 commit comments