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/02-structure/article.md
+16-16Lines changed: 16 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -48,51 +48,51 @@ alert(3 +
48
48
49
49
Bu kodun nəticəsi `6` olacaq, çünki, JavaScript interpretatoru burada nöqtəli vergül daxil etmir. JavaScript üçün intuitiv olaraq aydındır ki, əgər sətir `+` (üstəgəl) simvolu ilə bitirsə, bu "natamam ifadə"dir və nöqtəli vergül tələb olunmur. Bu halda kod gözlənildiyi kimi işləyir.
50
50
51
-
**But there are situations where JavaScript "fails" to assume a semicolon where it is really needed.**
51
+
**Amma müəyyən hallar da var ki, JavaScript belə hallarda nöqtəli vergülü avtomatik əlavə edə bilmir və nəticədə xəta yaranır.**
52
52
53
-
Errors which occur in such cases are quite hard to find and fix.
53
+
Belə hallarda xətaları tapmaq və düzəltmək olduqca çətin ola bilər.
54
54
55
-
````smart header="An example of an error"
56
-
If you're curious to see a concrete example of such an error, check this code out:
55
+
````smart header="Xəta üçün bir nümunə"
56
+
Əgər belə bir xətaya konkret nümunə görmək istəyirsinizsə, bu kodu yoxlayın:
57
57
58
58
```js run
59
59
[1, 2].forEach(alert)
60
60
```
61
61
62
-
No need to think about the meaning of the brackets `[]` and `forEach` yet. We'll study them later. For now, just remember the result of the code: it shows `1` then `2`.
62
+
İndilik `[]` (kvadrat mötərizələr) və `forEach` haqqında düşünməyə ehtiyac yoxdur. Onları daha sonra öyrənəcəyik. Hazırda sadəcə kodun nəticəsinə diqqət edin: bu kod əvvəlcə `1`, daha sonra `2` göstərəcək.
63
63
64
-
Now, let's add an `alert` before the code and *not* finish it with a semicolon:
64
+
İndi kodun əvvəlinə bir `alert` əlavə edək və onu nöqtəli vergülsüz bitirək:
65
65
66
66
```js run no-beautify
67
-
alert("There will be an error")
67
+
alert("Xəta baş verəcək")
68
68
69
69
[1, 2].forEach(alert)
70
70
```
71
71
72
-
Now if we run the code, only the first `alert` is shown and then we have an error!
72
+
İndi bu kodu işə salsaq, yalnız ilk `alert` mesajı görünəcək və daha sonra xəta ilə üzləşəcəyik!
73
73
74
-
But everything is fine again if we add a semicolon after `alert`:
74
+
Amma əgər `alert` ifadəsindən sonra nöqtəli vergül əlavə etsək, hər şey yenidən qaydasında olacaq:
75
75
```js run
76
-
alert("All fine now");
76
+
alert("Hər şey qaydasındadır.");
77
77
78
78
[1, 2].forEach(alert)
79
79
```
80
80
81
-
Now we have the "All fine now" message followed by `1` and `2`.
81
+
İndi "Hər şey qaydasındadır." mesajından sonra `1` və `2` görünür.
82
82
83
83
84
-
The error in the no-semicolon variant occurs because JavaScript does not assume a semicolon before square brackets `[...]`.
84
+
Nöqtəli vergülün olmadığı variantda xəta JavaScript'in kvadrat mötərizədən əvvəl nöqtəli vergülü avtomatik əlavə edə bilməməsindən qaynaqlanır.
85
85
86
-
So, because the semicolon is not auto-inserted, the code in the first example is treated as a single statement. Here's how the engine sees it:
86
+
Beləliklə, nöqtəli vergül avtomatik olaraq əlavə edilmədiyindən, ilk nümunədəki kod tək ifadə kimi qəbul olunur. JavaScript mühərriki kodu belə görür:
87
87
88
88
```js run no-beautify
89
-
alert("There will be an error")[1, 2].forEach(alert)
89
+
alert("Xəta baş verəcək")[1, 2].forEach(alert)
90
90
```
91
91
92
-
But it should be two separate statements, not one. Such a merging in this case is just wrong, hence the error. This can happen in other situations.
92
+
Amma kod iki ayrı ifadə olmalı idi, tək deyil. Bu halda birləşmə səhv baş verir və nəticədə xəta yaranır. Bu problem digər hallarda da yarana bilər.
93
93
````
94
94
95
-
We recommend putting semicolons between statements even if they are separated by newlines. This rule is widely adopted by the community. Let's note once again -- *it is possible* to leave out semicolons most of the time. But it's safer -- especially for a beginner -- to use them.
95
+
Əgər ifadələr sətirlərlə ayrılıbsa, onların arasına nöqtəli vergül qoymağı tövsiyə edirik. Bu qayda JavaScript cəmiyyəti tərəfindən geniş şəkildə qəbul olunub. Yenidən bir də qeyd edək ki, nöqtəli vergülləri çox vaxt buraxmaq -- *mümkündür*. Lakin, xüsusilə yeni başlayanlar üçün, nöqtəli vergüllərdən istifadə etmək daha təhlükəsizdir.
0 commit comments