Skip to content

Commit bd18ef3

Browse files
authored
Update article.md
1 parent e17d066 commit bd18ef3

File tree

1 file changed

+51
-51
lines changed

1 file changed

+51
-51
lines changed

1-js/02-first-steps/04-variables/article.md

+51-51
Original file line numberDiff line numberDiff line change
@@ -8,158 +8,158 @@ Kintamieji yra naudojami tam, kad kauptų šią informaciją.
88

99
## Kintamasis
1010

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

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").
1414

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":
1616

1717
```js
1818
let message;
1919
```
2020

21-
Now, we can put some data into it by using the assignment operator `=`:
21+
Dabar į jį galime patalpinti duomenis naudodami užduoties operatorių `=`:
2222

2323
```js
2424
let message;
2525

2626
*!*
27-
message = 'Hello'; // store the string
27+
message = 'Labas'; // patalpinama eilutė
2828
*/!*
2929
```
3030

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ą.
3232

3333
```js run
3434
let message;
35-
message = 'Hello!';
35+
message = 'Labas!';
3636

3737
*!*
38-
alert(message); // shows the variable content
38+
alert(message); // parodo kintamojo turinį
3939
*/!*
4040
```
4141

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ę:
4343

4444
```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ę
4646

47-
alert(message); // Hello!
47+
alert(message); // Labas!
4848
```
4949

50-
We can also declare multiple variables in one line:
50+
Mes taip pat galime deklaruoti kelis kintamuosius vienoje eilėje:
5151

5252
```js no-beautify
53-
let user = 'John', age = 25, message = 'Hello';
53+
let user = 'John', age = 25, message = 'Labas';
5454
```
5555

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

58-
The multiline variant is a bit longer, but easier to read:
58+
Kelių eilučių variantas ilgesnis, bet jį lengviau perskaityti:
5959

6060
```js
6161
let user = 'John';
6262
let age = 25;
63-
let message = 'Hello';
63+
let message = 'Labas';
6464
```
6565

66-
Some people also define multiple variables in this multiline style:
66+
Kai kurie žmonės apibrėžia kelis kintamuosius tokiu kelių eilių stiliumi:
6767
```js no-beautify
6868
let user = 'John',
6969
age = 25,
70-
message = 'Hello';
70+
message = 'Labas';
7171
```
7272

73-
...Or even in the "comma-first" style:
73+
...Arba netgi "kablelis priekyje" stiliumi:
7474

7575
```js no-beautify
7676
let user = 'John'
7777
, age = 25
78-
, message = 'Hello';
78+
, message = 'Labas';
7979
```
8080

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

8383

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

8787
```js
88-
*!*var*/!* message = 'Hello';
88+
*!*var*/!* message = 'Labas';
8989
```
9090

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

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>.
9494
````
9595
96-
## A real-life analogy
96+
## Tikro gyvenimo analogija
9797
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.
9999
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!"`:
101101
102102
![](variable.svg)
103103
104-
We can put any value in the box.
104+
Mes galime į dėžę įdėti bet kokią vertę.
105105
106-
We can also change it as many times as we want:
106+
Mes taip pat galime ją pakeisti kiek norime kartų:
107107
```js run
108108
let message;
109109
110-
message = 'Hello!';
110+
message = 'Labas!';
111111
112-
message = 'World!'; // value changed
112+
message = 'Pasauli!'; // vertė pakeista
113113
114114
alert(message);
115115
```
116116
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:
118118
119119
![](variable-change.svg)
120120
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ą.
122122
123123
```js run
124-
let hello = 'Hello world!';
124+
let hello = 'Labas pasauli!';
125125
126126
let message;
127127
128128
*!*
129-
// copy 'Hello world' from hello into message
129+
// nukopijuoti 'Labas pasauli' iš hello į message
130130
message = hello;
131131
*/!*
132132
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!
136136
```
137137
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.
140140
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.
142142
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ą.
144144
```
145145
146-
## Variable naming [#variable-naming]
146+
## Kintamųjų įvardinimas [#variable-naming]
147147
148-
There are two limitations on variable names in JavaScript:
148+
Yra du apribojimai kintamųjų pavadinimams JavaScript:
149149
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.
152152
153-
Examples of valid names:
153+
Tinkamų pavadinimų pavyzdžiai:
154154
155155
```js
156156
let userName;
157157
let test123;
158158
```
159159
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`.
161161
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.
163163
164164
These names are valid:
165165

0 commit comments

Comments
 (0)