Skip to content

Commit 9307cde

Browse files
GasimGasimzadaedevsh
authored andcommitted
Translate Variables page until Uppercase constants
1 parent a7590b0 commit 9307cde

File tree

1 file changed

+88
-88
lines changed

1 file changed

+88
-88
lines changed

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

Lines changed: 88 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,254 +1,254 @@
1-
# Variables
1+
# Dəyişənlər
22

3-
Most of the time, a JavaScript application needs to work with information. Here are two examples:
4-
1. An online shop -- the information might include goods being sold and a shopping cart.
5-
2. A chat application -- the information might include users, messages, and much more.
3+
Çox vaxt JavaScript applikasiyalarının məlumatlar ilə işləmələri lazımdır. Məsələn:
4+
1. onlayn mağaza applikasiyasında satılan mallar və alış-veriş səbəti haqqında məlumatlar lazımdır.
5+
2. çat applikasiyasında isitfadəçilər, ismarıclar və başqa maddələr haqqında məlumatlar lazımdır.
66

7-
Variables are used to store this information.
7+
Məlumatları saxlamaq üçün dəyişənlərdən istifadə edilir.
88

9-
## A variable
9+
## Dəyişən
1010

11-
A [variable](https://en.wikipedia.org/wiki/Variable_(computer_science)) is a "named storage" for data. We can use variables to store goodies, visitors, and other data.
11+
[Dəyişən](https://en.wikipedia.org/wiki/Variable_(computer_science)), məlumat üçün üçün "adlı saxlama yeridir." Dəyişənlər ilə mağaza malları, applikasiyaya ziyarət edənlər və digər məlumatları saxlamaq mümkündür.
1212

13-
To create a variable in JavaScript, use the `let` keyword.
13+
JavaScript-də dəyişən yaratmaq üçün `let` açar sözündən istifadə edin.
1414

15-
The statement below creates (in other words: *declares*) a variable with the name "message":
15+
Aşağıdakı ifadədə "message" adlı dəyişən yaradılır (digər sözlə, *bildirilir* ingiliscə, *declare*):
1616

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

21-
Now, we can put some data into it by using the assignment operator `=`:
21+
İndi, biz `=` təyinat operatorundan istifadə edərək bu dəyişənə məlumat təyin edə bilərik:
2222

2323
```js
2424
let message;
2525

2626
*!*
27-
message = 'Hello'; // store the string
27+
message = 'Salam'; // Mətni saxla
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+
İndi, mətn dəyəri dəyişənə bağlı olan yaddaş sahəsində saxlanılır. Biz, dəyişənin adından istifadə edərək bu dəyəri oxuya bilərik:
3232

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

3737
*!*
38-
alert(message); // shows the variable content
38+
alert(message); // dəyişənin kontentini göstər
3939
*/!*
4040
```
4141

42-
To be concise, we can combine the variable declaration and assignment into a single line:
42+
Yığcam kod yazmaq üçün biz dəyişənin yaranmasını və təyinatını bir sətirdə birləşdirə bilərik:
4343

4444
```js run
45-
let message = 'Hello!'; // define the variable and assign the value
45+
let message = 'Salam!'; // Dəyişəni müəyyənləşdir və dəyəri təyin et
4646

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

50-
We can also declare multiple variables in one line:
50+
Biz, həmçinin bir neçə dəyişəni eyni sətirdə müəyyənləşdirə bilərik:
5151

5252
```js no-beautify
53-
let user = 'John', age = 25, message = 'Hello';
53+
let user = 'Orxan', age = 25, message = 'Salam';
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+
Bunun daha qısa olmasına baxmayaraq biz belə kod yazmağı tövsiyyə etmirik. Oxunaqlığı çoxaltmaq üçün hər dəyişən üçün ayrı sətir işlədin.
5757

58-
The multiline variant is a bit longer, but easier to read:
58+
Çox sətirli variantın biraz uzun olmasına baxmayaraq bunu oxumaq daha asandır:
5959

6060
```js
61-
let user = 'John';
61+
let user = 'Orxan';
6262
let age = 25;
63-
let message = 'Hello';
63+
let message = 'Salam';
6464
```
6565

66-
Some people also define multiple variables in this multiline style:
66+
Bəzi proqramçılar bir neçə dəyişəni aşağıdakı formada:
6767
```js no-beautify
68-
let user = 'John',
68+
let user = 'Orxan',
6969
age = 25,
70-
message = 'Hello';
70+
message = 'Salam';
7171
```
7272

73-
...Or even in the "comma-first" style:
73+
...vı ya "vergül-birinci" stilində də müəyyənləşdirirlər:
7474

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

81-
Technically, all these variants do the same thing. So, it's a matter of personal taste and aesthetics.
81+
Texniki olaraq yuxarıdakı bütün variantlar eyni nəticəni verəcək. Bu səbəbdən, burada vacib olan proqramçıların şəxsi zövqüdür.
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="`let` əvəzinə `var`"
85+
Siz, köhnə skriptlərdə `let` əvəzinə `var` açar sözünün işlədildiyini görə bilərsiniz:
8686

8787
```js
88-
*!*var*/!* message = 'Hello';
88+
*!*var*/!* message = 'Salam';
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+
`var` dəyişəni *az qala* `let` ilə eynidir. Bu açar sözü dəyişənin daha "köhnə" üsul ilə müəyyənləşdirir.
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+
`let` `var` arasında olan hiss edilməyən fərqlər var. Lakin, indi bu fərqlər bizi maralandırmır. Biz, bu fərqlər haqqında <info:var> bölməsində detallı danışacağıq.
9494
````
9595
96-
## A real-life analogy
96+
## Real dünyada analogiya
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+
"Dəyişən" konsepsiyasını yaxşı anlamaq üçün bunun, üzərində unikal adlı etiketi olan məlumatlar "qutusu" olduğunu fikirləşin.
9999
100-
For instance, the variable `message` can be imagined as a box labeled `"message"` with the value `"Hello!"` in it:
100+
Məsələn, `message` dəyişəni daxilində "Salam!" dəyəri olan və `"message"` adı ilə etiketlənən qutudur:
101101
102102
![](variable.svg)
103103
104-
We can put any value in the box.
104+
Biz qutuda istənilən dəyəri yerləşdirə bilərik.
105105
106-
We can also change it as many times as we want:
106+
Əlavə olaraq, biz bu dəyəri istədiyimiz qədər dəyişə bilərik:
107107
```js run
108108
let message;
109109
110-
message = 'Hello!';
110+
message = 'Salam!';
111111
112-
message = 'World!'; // value changed
112+
message = 'Dünya!'; // dəyər dəyişdi
113113
114114
alert(message);
115115
```
116116
117-
When the value is changed, the old data is removed from the variable:
117+
Dəyər dəyişdikdə dəyişəndə olan köhnə məlumat silinir:
118118
119119
![](variable-change.svg)
120120
121-
We can also declare two variables and copy data from one into the other.
121+
Əlavə olaraq, biz iki dəyişən yaradıb birinin məlumatını o birisinə kopiyalaya bilərik.
122122
123123
```js run
124-
let hello = 'Hello world!';
124+
let hello = 'Salam dünya!';
125125
126126
let message;
127127
128128
*!*
129-
// copy 'Hello world' from hello into message
129+
// 'Salam dünya' dəyərini hello dəyişənindən message dəyişəninə kopiyala
130130
message = hello;
131131
*/!*
132132
133-
// now two variables hold the same data
134-
alert(hello); // Hello world!
135-
alert(message); // Hello world!
133+
// indi, hər iki dəyişəndə eyni dəyər saxlanılır
134+
alert(hello); // Salam dünya!
135+
alert(message); // Salam dünya!
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="Funksional dillər"
139+
Nəzərinizə çatdırmaq istəyirik ki, [Scala](http://www.scala-lang.org/) və [Erlang](http://www.erlang.org/) kimi [funksional](https://en.wikipedia.org/wiki/Functional_programming) proqramlaşdırma dillərində dəyişənin dəyişilməsinə icazə verilmir.
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+
Bu dillərdə, dəyər "qutuya" yerləşdirildikdən sonra orada ömürlük qalır. Fərqli məlumat saxlamaq istədikdə proqramlaşdırma dili bizə yeni qutu (dəyişənin yaradılması) yaratmağa məcbur edir. Biz köhnə dəyəri yenidən təyin edə bilmirik.
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+
İlk baxışda bunun biraz qəribə olmasına baxmayaraq bu dillərdə çox ciddi təkmilləşdirmə etmək mümkündür. Bundan əlavə, paralel hesablamalar kimi bəzi tapşırıqlarda bu məhdudiyyətin olmasının faydası var. Fikrinizi genişləndirmək üçün bu formalı dili öyrənməyi (hətta bunu işlətməyi planlaşdırmasanız belə) tövsiyyə edirik.
144144
```
145145
146-
## Variable naming [#variable-naming]
146+
## Dəyişənlərin adlandırılması [#variable-naming]
147147
148-
There are two limitations on variable names in JavaScript:
148+
JavaScript-də dəyişənlərin adlandırılmasında iki məhdudiyyət var:
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. Dəyişən adında yalnız hərflər, rəqəmlər və ya `$` `_` kimi simvollar ola bilər.
151+
2. Dəyişən adının ilk hərfi rəqəm ola bilməz.
152152
153-
Examples of valid names:
153+
Etibarlı adlar üçün nümunələr:
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+
Dəyişən adı bir neçə sözdən ibarət olduqda çox zaman [camelCase](https://en.wikipedia.org/wiki/CamelCase) formatından istifadə olunur. Bu formatında ilk sözdən başqa bütün sözlər böyük hərf ilə başlayır: `myVeryLongName`.
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+
Dəyişən adlarında dollar (`'$'`) altdan xətt (`'_'`) işarələrinin də işlədilə bilməsi maraqlıdır. Bu simvollar, hərflər kimi xüsusi mənası olmayan sadə simvollardır.
163163
164-
These names are valid:
164+
Aşağıdakı dəyişən adlar etibarlıdır:
165165
166166
```js run untrusted
167-
let $ = 1; // declared a variable with the name "$"
168-
let _ = 2; // and now a variable with the name "_"
167+
let $ = 1; // "$" adlı dəyişən təyin et
168+
let _ = 2; // "_" adlı dəyişən təyin et
169169
170170
alert($ + _); // 3
171171
```
172172
173-
Examples of incorrect variable names:
173+
Səhv məlumat adlarının nümunələri:
174174
175175
```js no-beautify
176-
let 1a; // cannot start with a digit
176+
let 1a; // dəyişən adı rəqəm ilə başlaya bilməz
177177
178-
let my-name; // hyphens '-' aren't allowed in the name
178+
let my-name; // dəyişən adında '-' kimi simvollar ola bilməz
179179
```
180180
181181
```smart header="Case matters"
182-
Variables named `apple` and `AppLE` are two different variables.
182+
`apple` `AppLE` adları fərqli dəyişənlərə istinad edir.
183183
```
184184
185-
````smart header="Non-Latin letters are allowed, but not recommended"
186-
It is possible to use any language, including cyrillic letters or even hieroglyphs, like this:
185+
````smart header="Latın adlarını işlətmək olar, amma tövsiyyə edilmir"
186+
Kiril hərfləri və iyeroqlif daxil olmaqla istənilən dildə olan hərfləri işlətmək olar:
187187
188188
```js
189189
let имя = '...';
190190
let 我 = '...';
191191
```
192192
193-
Technically, there is no error here, such names are allowed, but there is an international tradition to use English in variable names. Even if we're writing a small script, it may have a long life ahead. People from other countries may need to read it some time.
193+
Texniki olaraq, burada heç bir xəta yoxdur. Lakin, beynəlxalq ənənəyə görə dəyişən adları İngiliscə yazılır. Kiçik skript yazsaq belə bu skriptin uzun həyatı ola bilər. Digər ölkələrdə olan proqramistlər bu skripti oxumalı ola bilərlər.
194194
````
195195

196-
````warn header="Reserved names"
197-
There is a [list of reserved words](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#Keywords), which cannot be used as variable names because they are used by the language itself.
196+
````warn header="Qorunan adlar"
197+
JavaScript dilində işlədilən bəzi [qorunan sözləri](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#Keywords) dəyişən adı kimi işlətmək olmaz.
198198
199-
For example: `let`, `class`, `return`, and `function` are reserved.
199+
Məsələn: `let`, `class`, `return` `function` sözləri qorunur.
200200
201-
The code below gives a syntax error:
201+
Aşağıdakı kodda sintaksis xətası baş verəcək:
202202
203203
```js run no-beautify
204-
let let = 5; // can't name a variable "let", error!
205-
let return = 5; // also can't name it "return", error!
204+
let let = 5; // xəta! "let" adlı dəyişən işlətmək olmaz!
205+
let return = 5; // xəta! "return" adlı dəyişən işlətmək olmaz!
206206
```
207207
````
208208

209-
````warn header="An assignment without `use strict`"
209+
````warn header="`use strict`-siz təyinat"
210210

211-
Normally, we need to define a variable before using it. But in the old times, it was technically possible to create a variable by a mere assignment of the value without using `let`. This still works now if we don't put `use strict` in our scripts to maintain compatibility with old scripts.
211+
Normalda, dəyişəni işlətməmişdən öncə bu dəyişəni yaratmaq lazımdır. Lakin, keçmişdə dəyişəni `let` kimi açar sözü işlətmədən müəyyənləşdirmək mümkün idi. Skriptlərə `use strict` əlavə etmədikdə bu formada olan kodlar işləyəcək.
212212

213213
```js run no-strict
214-
// note: no "use strict" in this example
214+
// qeyd: bu nümunədə "use strict" işlədilmir
215215

216-
num = 5; // the variable "num" is created if it didn't exist
216+
num = 5; // "num" dəyişəni olmadıqda dəyişən yaranacaq
217217

218218
alert(num); // 5
219219
```
220220

221-
This is a bad practice and would cause an error in strict mode:
221+
Bunun pis praktika olduğundan bu sizə strikt rejimində xəta verəcək:
222222

223223
```js
224224
"use strict";
225225

226226
*!*
227-
num = 5; // error: num is not defined
227+
num = 5; // xəta: num təyin edilməyib
228228
*/!*
229229
```
230230
````
231231
232-
## Constants
232+
## Sabit dəyişənlər
233233
234-
To declare a constant (unchanging) variable, use `const` instead of `let`:
234+
Sabit (dəyişməyən) dəyişən yaratmaq istəyirsinizsə, `let` əvəzinə `const` işlədin:
235235
236236
```js
237237
const myBirthday = '18.04.1982';
238238
```
239239
240-
Variables declared using `const` are called "constants". They cannot be reassigned. An attempt to do so would cause an error:
240+
`const` ilə yaranan dəyişənlər "sabit dəyişənlər" adlandırılır. Bu dəyişənləri yenidən təyin etmək mümkün deyil. Dəyişənin dəyərini dəyişmək istədikdə xəta baş verəcək:
241241
242242
```js run
243243
const myBirthday = '18.04.1982';
244244
245-
myBirthday = '01.01.2001'; // error, can't reassign the constant!
245+
myBirthday = '01.01.2001'; // xəta, sabit dəyişəni dəyişmək olmaz!
246246
```
247247
248-
When a programmer is sure that a variable will never change, they can declare it with `const` to guarantee and clearly communicate that fact to everyone.
248+
Proqramçı dəyişənin heç vaxt dəyişməyəcəyindən əmin olduqda dəyişəni `const` ilə təyin edərək bu dəyişənin dəyişməyəcəyini siğortalayıb digər proqramçılara bildirə bilər.
249249
250250
251-
### Uppercase constants
251+
### Böyük hərf ilə yazılmış sabit dəyişənlər
252252
253253
There is a widespread practice to use constants as aliases for difficult-to-remember values that are known prior to execution.
254254

0 commit comments

Comments
 (0)