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/09-comparison/article.md
+24-24Lines changed: 24 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,9 +9,9 @@ JavaScript'те алар мындай жазылат:
9
9
- Барабар: `a == b`, көңүл буруңуз, кош барабардык белгиси `==` салыштыруу үчүн колдонулат, ал эми жалгыз барабардык белгиси `a = b` ыйгарууну билдирчү.
10
10
- Барабар эмес: Математикада <code>≠</code> белгиси менен белгиленет, бирок JavaScript'те <code>a != b</code> деп жазылат.
11
11
12
-
In this article we'll learn more about different types of comparisons, how JavaScript makes them, including important peculiarities.
12
+
Бул бөлүмдө биз салыштыруунун ар кандай түрлөрү, JavaScript аларды кантип аткарышы жана маанилүү өзгөчөлүктөрү жөнүндө көбүрөөк үйрөнөбүз.
13
13
14
-
At the end you'll find a good recipe to avoid "JavaScript quirks"-related issues.
14
+
Аягында, сиз JavaScript'теги салыштыруу "тентектиктеринен" сактануу үчүн жакшы кеңештерди таба аласыз.
A comparison result can be assigned to a variable, just like any value:
31
+
Салыштыруунун натыйжасы ар кандай маани сыяктуу эле өзгөрмөгө ыйгарылышы мүмкүн:
32
32
33
33
```js run
34
34
let result =5>4; // салыштыруунун натыйжасы result өзгөрмөсүнө ыйгарылат
@@ -37,27 +37,27 @@ alert( result ); // true
37
37
38
38
## Саптарды салыштыруу
39
39
40
-
To see whether a string is greater than another, JavaScript uses the so-called "dictionary" or "lexicographical" order.
40
+
Бир сап экинчисинен чоңураак экенин аныктоо үчүн JavaScript "алфавиттик" же "лексикографиялык" деп аталган тартипти колдонот.
41
41
42
-
In other words, strings are compared letter-by-letter.
42
+
Башкача айтканда, саптар белгиден белгиге салыштырылат.
43
43
44
44
Мисалы:
45
45
46
46
```js run
47
47
alert( 'Я'>'А' ); // туура (true)
48
48
alert( 'Кант'>'Калп' ); // туура (true)
49
-
alert( 'Бала'>'Бал' ); // туура (true)
49
+
alert( 'Балдар'>'Бал' ); // туура (true)
50
50
```
51
51
52
52
Эки сапты салыштыруу алгоритми абдан жөнөкөй:
53
53
54
-
1.Compare the first character of both strings.
55
-
2.If the first character from the first string is greater (or less) than the other string's, then the first string is greater (or less) than the second. We're done.
56
-
3.Otherwise, if both strings' first characters are the same, compare the second characters the same way.
57
-
4.Repeat until the end of either string.
58
-
5.If both strings end at the same length, then they are equal. Otherwise, the longer string is greater.
54
+
1.Эки саптын биринчи белгилери салыштырылат.
55
+
2.Эгерде биринчи саптын биринчи белгиси башка саптардан чоң (же кичине) болсо, биринчи сап экинчисинен чоң (же кичине) болот. Салыштыруу аяктады.
56
+
3.Болбосо, эки саптын тең биринчи белгилери бирдей болсо, экинчи белгилери ошондой жол менен эле салыштырылат.
57
+
4.Салыштыруу саптардын бири бүтмөйүнчө уланат.
58
+
5.Эгерде эки сап бирдей узундукта аяктаса, анда алар барабар болот. Болбосо, узун сап чоңураак болуп саналат.
59
59
60
-
In the first example above, the comparison `'Z' > 'A'`gets to a result at the first step.
60
+
Жогорудагы биринчи мисалда `'Я' > 'А'`салыштыруусу биринчи кадамда аяктайт.
61
61
62
62
Экинчи `'Кант'` жана `'Калп'` сөздөрүнүн салыштыруусу белгиден белгиге салыштырылат:
63
63
@@ -71,18 +71,18 @@ The comparison algorithm given above is roughly equivalent to the one used in di
71
71
For instance, case matters. A capital letter `"A"` is not equal to the lowercase `"a"`. Which one is greater? The lowercase `"a"`. Why? Because the lowercase character has a greater index in the internal encoding table JavaScript uses (Unicode). We'll get back to specific details and consequences of this in the chapter <info:string>.
72
72
```
73
73
74
-
## Comparison of different types
74
+
## Ар кандай түрлөрдү салыштыруу
75
75
76
-
When comparing values of different types, JavaScript converts the values to numbers.
76
+
Ар кандай түрдөгү маанилер салыштырылганда, JavaScript ошол маанилерди сандарга айландырат.
77
77
78
-
For example:
78
+
Мисалы:
79
79
80
80
```js run
81
-
alert( '2'>1 ); // true, string '2' becomes a number 2
82
-
alert( '01'==1 ); // true, string '01' becomes a number 1
81
+
alert( '2'>1 ); // true, '2' сабы 2 санына айланат
82
+
alert( '01'==1 ); // true, '01' сабы 1 санына айланат
83
83
```
84
84
85
-
For boolean values, `true`becomes`1`and `false`becomes`0`.
85
+
Логикалык `true`мааниси`1`болуп калат жана `false`мааниси`0` болуп калат.
86
86
87
87
Мисалы:
88
88
@@ -92,10 +92,10 @@ alert( false == 0 ); // true
92
92
```
93
93
94
94
````smart header="A funny consequence"
95
-
It is possible that at the same time:
95
+
Төмөнкү кырдаал болушу мүмкүн:
96
96
97
-
- Two values are equal.
98
-
- One of them is `true` as a boolean and the other one is `false` as a boolean.
97
+
- Эки маани барабар.
98
+
- Алардын бири логикалык `true` мааниси, экинчиси - `false`.
99
99
100
100
Мисалы:
101
101
@@ -112,15 +112,15 @@ alert(a == b); // true!
112
112
From JavaScript's standpoint, this result is quite normal. An equality check converts values using the numeric conversion (hence `"0"` becomes `0`), while the explicit `Boolean` conversion uses another set of rules.
113
113
````
114
114
115
-
## Strict equality
115
+
## Катуу салыштыруу
116
116
117
-
A regular equality check `==`has a problem. It cannot differentiate `0`from`false`:
117
+
Кадимки салыштыруу операторунун `==`көйгөйү бар. Ал `0`менен`false` маанилерин айырмалай албайт:
0 commit comments