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
Note, we could use a shorter name `planet`, but it might be not obvious what planet it refers to. It's nice to be more verbose. At least until the variable isNotTooLong.
9
+
Nəzərə alın ki, biz `planet` adından istifadə edə bilərdik. Lakin, bu ad ilə hansı planetdən danışdığımız bilinməyəcəkdi. Daha məlumatlı adlar yazmaq yaxşıdır.
10
10
11
-
## The name of the current visitor
11
+
## Cari ziyarətçinin adı
12
12
13
13
```js
14
-
let currentUserName ="John";
14
+
let currentUserName ="Orxan";
15
15
```
16
16
17
-
Again, we could shorten that to `userName` if we know for sure that the user is current.
17
+
Biz bu dəyişənin həmişə cari istifadəçi haqqında olduğunu bilsəydik bu dəyişəni `userName` adlandıra bilərdik.
18
18
19
-
Modern editors and autocomplete make long variable names easy to write. Don't save on them. A name with 3 words in it is fine.
19
+
Modern redaktorlarda olan avtomatik tamamlayıcı qurğular ilə uzun adları yazmaq asanlaşır. Üç sözdən ibarət ad normaldır.
20
20
21
-
And if your editor does not have proper autocompletion, get [a new one](/code-editors).
21
+
Əgər redaktorununzda avtomatik tamamlayıcı qurğu yoxdursa, [yeni redaktor əldə edin](/code-editors).
We generally use upper case for constants that are "hard-coded". Or, in other words, when the value is known prior to execution and directly written into the code.
1
+
Normalda, biz əl ilə yazılan sabit dəyişənləri böyük hərf ilə yazırıq. Digər sözlə, dəyişənin dəyəri skriptin icrasından öncə bilindikdə və kodda birbaşa yazıldıqda biz bu dəyişəni böyük hərf ilə yazırıq.
2
2
3
-
In this code, `birthday`is exactly like that. So we could use the upper case for it.
3
+
Bu kodda, `birthday`dəyişəninin bu formada olduğundan biz böyük hərfdən istifadə edə bilərik.
4
4
5
-
In contrast, `age`is evaluated in run-time. Today we have one age, a year after we'll have another one. It is constant in a sense that it does not change through the code execution. But it is a bit "less of a constant" than `birthday`: it is calculated, so we should keep the lower case for it.
5
+
Lakin, `age`dəyişəni icra zamanı hesablanır. Bugün bizdə bir yaş, bir il sonra isə fərqli yaş olacaq. Bu dəyişən kod icrası zamanı dəyişmir amma bu dəyişən hesablanır deyə `birthday`-dən daha "az sabitdir". Bu səbəbdən, bu dəyişənin adı böyük hərf ilə yazılmamalıdır.
Copy file name to clipboardExpand all lines: 1-js/02-first-steps/04-variables/3-uppercast-constant/task.md
+6-6
Original file line number
Diff line number
Diff line change
@@ -2,23 +2,23 @@ importance: 4
2
2
3
3
---
4
4
5
-
# Uppercase const?
5
+
# Böyük hərf ilə const?
6
6
7
-
Examine the following code:
7
+
Aşağıdakı koda baxın:
8
8
9
9
```js
10
10
constbirthday='18.04.1982';
11
11
12
12
constage=someCode(birthday);
13
13
```
14
14
15
-
Here we have a constant `birthday`date and the `age` is calculated from `birthday` with the help of some code (it is not provided for shortness, and because details don't matter here).
15
+
Burada `birthday`adlı sabit zaman dəyişəni və `birthday`-dən hesablanan `age` sabit dəyişəni var (hesablama funksiyasının vacib olmadığından bu kodun tətbiq detalı göstərilməyib).
16
16
17
-
Would it be right to use upper case for `birthday`? For`age`? Or even for both?
17
+
`birthday` üçün böyük hərf işlətmək yaxşı fikirdir? Bəs`age` üçün? Bəs hər ikisi üçün?
18
18
19
19
```js
20
-
constBIRTHDAY='18.04.1982'; //make uppercase?
20
+
constBIRTHDAY='18.04.1982'; //böyük hərf ilə yazaq?
21
21
22
-
constAGE=someCode(BIRTHDAY); //make uppercase?
22
+
constAGE=someCode(BIRTHDAY); //böyük hərf ilə yazaq?
Copy file name to clipboardExpand all lines: 1-js/02-first-steps/04-variables/article.md
+38-38
Original file line number
Diff line number
Diff line change
@@ -250,81 +250,81 @@ Proqramçı dəyişənin heç vaxt dəyişməyəcəyindən əmin olduqda dəyiş
250
250
251
251
### Böyük hərf ilə yazılmış sabit dəyişənlər
252
252
253
-
There is a widespread practice to use constants as aliases for difficult-to-remember values that are known prior to execution.
253
+
Praktikada, çətin yadda qalan dəyərlər skript icra olunmamışdan öncə sabit dəyişələr ilə ləqəbləndirilir.
254
254
255
-
Such constants are named using capital letters and underscores.
255
+
Bu formalı sabit dəyişənlər böyük hərf və altdan xətt ilə adlandırılırlar.
256
256
257
-
For instance, let's make constants for colors in so-called "web" (hexadecimal) format:
257
+
Məsələn, gəlin "veb" (16-lı rəqəm) formatında olan rənglər üçün sabit dəyişənlər yaradaq:
258
258
259
259
```js run
260
260
const COLOR_RED = "#F00";
261
261
const COLOR_GREEN = "#0F0";
262
262
const COLOR_BLUE = "#00F";
263
263
const COLOR_ORANGE = "#FF7F00";
264
264
265
-
// ...when we need to pick a color
265
+
// ...rəngdən istifadə etdikdə
266
266
let color = COLOR_ORANGE;
267
267
alert(color); // #FF7F00
268
268
```
269
269
270
-
Benefits:
270
+
Faydaları:
271
271
272
-
- `COLOR_ORANGE` is much easier to remember than `"#FF7F00"`.
273
-
- It is much easier to mistype `"#FF7F00"` than `COLOR_ORANGE`.
274
-
- When reading the code, `COLOR_ORANGE` is much more meaningful than `#FF7F00`.
272
+
- `COLOR_ORANGE` dəyəri yadda saxlamaq `"#FF7F00"` dəyərini yadda saxlamaqdan daha asandır.
273
+
- `"#FF7F00"` dəyərində səhv etmək `COLOR_ORANGE` dəyərində səhv etməkdən daha asandır.
274
+
- Kodu oxuduqda `COLOR_ORANGE` dəyərinin mənası `#FF7F00` dəyərinin mənasından daha çoxdur.
275
275
276
-
When should we use capitals for a constant and when should we name it normally? Let's make that clear.
276
+
Sabit dəyişənləri nə zaman normal formada, nə zaman isə böyük hərflər ilə yazmaq lazımdır? Gəlin bunun açıqlamasını verək.
277
277
278
-
Being a "constant" just means that a variable's value never changes. But there are constants that are known prior to execution (like a hexadecimal value for red) and there are constants that are *calculated* in run-time, during the execution, but do not change after their initial assignment.
278
+
Dəyişənin "sabit" olması, bu dəyişənin heç vaxt dəyişməməsi deməkdir. Lakin, bəzi sabit dəyişənlər skript icra olunmamışdan öncə (qırmızı rəngin 16-lıq rəqəmi kimi) , bəziləri isə icra zamanı *hesablanır* və sabit qalır.
279
279
280
-
For instance:
280
+
Məsələn:
281
281
```js
282
-
const pageLoadTime = /* time taken by a webpage to load */;
282
+
const pageLoadTime = /* veb səhifənin yüklənməsinə xərclənən zaman */;
283
283
```
284
284
285
-
The value of `pageLoadTime` is not known prior to the page load, so it's named normally. But it's still a constant because it doesn't change after assignment.
285
+
`pageLoadTime` dəyəri səhifə yüklənməmişdən öncə bilinmədiyindən bu, normal adlandırılır. Lakin, bu dəyər təyin edildikdən sonra dəyişmədiyindən sabit qalır.
286
286
287
-
In other words, capital-named constants are only used as aliases for "hard-coded" values.
287
+
Digər sözlə, böyük hərf ilə yazılan sabit dəyişənləri yalnız "əl ilə" yazılan dəyərlər üçün istifadə edin.
288
288
289
-
## Name things right
289
+
## Dəyişənləri düzgün adlandırın
290
290
291
-
Talking about variables, there's one more extremely important thing.
291
+
Dəyişənləri adlandırdıqda çox vacib məqam var.
292
292
293
-
A variable name should have a clean, obvious meaning, describing the data that it stores.
293
+
Dəyişən adının saxladığı məlumatı təsvir edən təmin və mənalı adı olmalıdır.
294
294
295
-
Variable naming is one of the most important and complex skills in programming. A quick glance at variable names can reveal which code was written by a beginner versus an experienced developer.
295
+
Dəyişənləri adlandırmaq proqramlaşdırmada çox vacib və mürəkkəb bacarıqlardan biridir. Dəyişənin adına baxdıqda kodun yenibaşlayan və ya təcrübəli proqramçının yazdığını bilmək mümkündür.
296
296
297
-
In a real project, most of the time is spent modifying and extending an existing code base rather than writing something completely separate from scratch. When we return to some code after doing something else for a while, it's much easier to find information that is well-labeled. Or, in other words, when the variables have good names.
297
+
Real layihədə işlədikdə vaxtın çoxu sıfırdan kod yazmaq əvəzinə mövcud kodu dəyişməyə və artırmağa gedir. Digər tapşırıqlardan kodunuza qayıtdıqda yaxşı adlandırılmış məlumatları tapmaq daha asandır. Digər sözlə dəyişənləri yaxşı adlandırmaq lazımdır.
298
298
299
-
Please spend time thinking about the right name for a variable before declaring it. Doing so will repay you handsomely.
299
+
Dəyişəni müəyyənləşdirməmişdən öncə yaxşı ad haqqında biraz fikirləşin. Bunu etdikdə faydasını görəcəksiniz.
300
300
301
-
Some good-to-follow rules are:
301
+
Bəzi əməl edə biləcəyiniz yaxşı qaydalar:
302
302
303
-
- Use human-readable names like `userName` or `shoppingCart`.
304
-
- Stay away from abbreviations or short names like `a`, `b`, `c`, unless you really know what you're doing.
305
-
- Make names maximally descriptive and concise. Examples of bad names are `data` and `value`. Such names say nothing. It's only okay to use them if the context of the code makes it exceptionally obvious which data or value the variable is referencing.
306
-
- Agree on terms within your team and in your own mind. If a site visitor is called a "user" then we should name related variables `currentUser` or `newUser` instead of `currentVisitor` or `newManInTown`.
303
+
- `userName` və ya `shoppingCart` kimi insanların başa düşə biləcəyi adlardan istifadə edin.
304
+
- Qısaldılmış adlardan və ya `a`, `b`, `c` kimi adlardan uzaq durun.
305
+
- Adları maksimal dərəcədə təsvirli və dəqiq edin. `data` və `value` kimi adlar pisdir. Bu adlar nəyin baş verdiyi haqqda heç nə təsvir etmir. Əgər kodun konteksti dəyişənin hansı məlumat və ya dəyərə istinad etdiyini göstərirsə, belə adlardan istifadə etmək olar.
306
+
- Komandanızda və beyninizdə terminlər haqqında razılığıa gəlin. Əgər sayt ziyatətçisi "user" adlanırsa, buna aid dəyişənləri `currentVisitor` və ya `newManInTown` adlandırmaq əvəzinə `currentUser` və ya `newUser` adlandırın.
307
307
308
-
Sounds simple? Indeed it is, but creating descriptive and concise variable names in practice is not. Go for it.
308
+
Sadə görünür? Bunun sadə görünməyinə baxmayaraq praktikada təsvirli və dəqiq dəyişən adları düzəltmək çətindir.
309
309
310
-
```smart header="Reuse or create?"
311
-
And the last note. There are some lazy programmers who, instead of declaring new variables, tend to reuse existing ones.
310
+
```smart header="Yenidən işlət yoxsa yarat?"
311
+
Bəzi avara proqramçılar yeni dəyişən yaratmaq əvəzinə mövcud dəyişəni istifadə etməyi sevirlər.
312
312
313
-
As a result, their variables are like boxes into which people throw different things without changing their stickers. What's inside the box now? Who knows? We need to come closer and check.
313
+
Nəticədə, bu dəyişənlər etiketi dəyişməyən, amma daxili dəyişən qutulara bənzəyirlər. Qutunun içində nəyin olduğunu heç kim bilmir. Bu səbəbdən, biz bu kodlara yaxından baxım yoxlamalıyıq.
314
314
315
-
Such programmers save a little bit on variable declaration but lose ten times more on debugging.
315
+
Bu proqramçılar dəyişən yaratmaqda az vaxt, amma debaq zamanı on dəfə çox vaxt xərcləyirlər.
316
316
317
-
An extra variable is good, not evil.
317
+
Yeni dəyişən yaratmaq pis deyil.
318
318
319
-
Modern JavaScript minifiers and browsers optimize code well enough, so it won't create performance issues. Using different variables for different values can even help the engine optimize your code.
319
+
Modern JavaScript minifikasiya edici qurğuları və brauzerlər kodu yaxşı optimallaşdırırlar. Bu səbəbdən, çox dəyişən yaratdıqda performans problemləri yaranmayacaq. Fərqli dəyərlər üçün fərqli dəyişənlər işlətdikdə JavaScript mühərriki kodunuzu daha da yaxşı optimizasiya edə bilər.
320
320
```
321
321
322
-
## Summary
322
+
## Xülasə
323
323
324
-
We can declare variables to store data by using the `var`, `let`, or `const` keywords.
324
+
Dəyişənləri `var`, `let` və ya `const` açar sözləri ilə yaratmaq mümkündür.
325
325
326
-
- `let` -- is a modern variable declaration.
327
-
- `var` -- is an old-school variable declaration. Normally we don't use it at all, but we'll cover subtle differences from `let` in the chapter <info:var>, just in case you need them.
328
-
- `const` -- is like `let`, but the value of the variable can't be changed.
326
+
- `let` -- modern dəyişən yaratmaq üçün işlədilir.
327
+
- `var` -- köhnə üsulda dəyişən yaratmaq üçün işlədilir. Normalda, biz bu dəyişəndən istifadə etmirik, amma <info:var> bölməsində `let` və `var` arasında olan fərqlərdən danışacağıq.
328
+
- `const` -- `let` kimidir. Lakin, bununla yaranan dəyişənin dəyəri dəyişə bilməz.
329
329
330
-
Variables should be named in a way that allows us to easily understand what's inside them.
330
+
Dəyişənləri, təyin olunan dəyəri yaxşı başa salan adlar ilə adlandırmağı tövsiyyə edirik.
0 commit comments