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
-Чоң/кичине же барабар: <code>a >= b</code>, <code>a <= b</code>.
9
+
-Барабар: `a == b`, көңүл буруңуз, кош барабардык белгиси `==`салыштыруу үчүн колдонулат, ал эми жалгыз барабардык белгиси `a = b`ыйгарууну билдирчү.
10
+
-Барабар эмес: Математикада <code>≠</code> белгиси менен белгиленет, бирок JavaScript'те <code>a != b</code> деп жазылат.
11
11
12
12
In this article we'll learn more about different types of comparisons, how JavaScript makes them, including important peculiarities.
13
13
14
14
At the end you'll find a good recipe to avoid "JavaScript quirks"-related issues.
15
15
16
-
## Boolean is the result
16
+
## Салыштыруунун натыйжасы логикалык түргө ээ
17
17
18
-
All comparison operators return a boolean value:
18
+
Бардык салыштыруу операторлору логикалык түрдөгү маанини кайтарат:
19
19
20
-
-`true` -- means "yes", "correct" or "the truth".
21
-
-`false` -- means "no", "wrong" or "not the truth".
20
+
-`true` -- "ооба", "туура" же "чындыкты" билдирет.
21
+
-`false` -- "жок", "туура эмес" же "жалганды" билдирет.
22
22
23
-
For example:
23
+
Мисалы:
24
24
25
25
```js run
26
-
alert( 2>1 ); // true (correct)
27
-
alert( 2==1 ); // false (wrong)
28
-
alert( 2!=1 ); // true (correct)
26
+
alert( 2>1 ); // true (туура)
27
+
alert( 2==1 ); // false (туура эмес)
28
+
alert( 2!=1 ); // true (туура)
29
29
```
30
30
31
31
A comparison result can be assigned to a variable, just like any value:
32
32
33
33
```js run
34
-
let result =5>4; //assign the result of the comparison
34
+
let result =5>4; //салыштыруунун натыйжасы result өзгөрмөсүнө ыйгарылат
35
35
alert( result ); // true
36
36
```
37
37
38
-
## String comparison
38
+
## Саптарды салыштыруу
39
39
40
40
To see whether a string is greater than another, JavaScript uses the so-called "dictionary" or "lexicographical" order.
41
41
42
42
In other words, strings are compared letter-by-letter.
43
43
44
-
For example:
44
+
Мисалы:
45
45
46
46
```js run
47
-
alert( 'Z'>'A' ); // true
48
-
alert( 'Glow'>'Glee' ); // true
49
-
alert( 'Bee'>'Be' ); // true
47
+
alert( 'Я'>'А' ); //туура (true)
48
+
alert( 'Кант'>'Калп' ); //туура (true)
49
+
alert( 'Бала'>'Бал' ); //туура (true)
50
50
```
51
51
52
-
The algorithm to compare two strings is simple:
52
+
Эки сапты салыштыруу алгоритми абдан жөнөкөй:
53
53
54
54
1. Compare the first character of both strings.
55
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.
@@ -59,11 +59,11 @@ The algorithm to compare two strings is simple:
59
59
60
60
In the first example above, the comparison `'Z' > 'A'` gets to a result at the first step.
61
61
62
-
The second comparison `'Glow'`and`'Glee'`needs more steps as strings are compared character-by-character:
62
+
Экинчи `'Кант'`жана`'Калп'`сөздөрүнүн салыштыруусу белгиден белгиге салыштырылат:
63
63
64
-
1.`G` is the same as `G`.
65
-
2.`l` is the same as `l`.
66
-
3.`o` is greater than `e`. Stop here. The first string is greater.
64
+
1.`К` менен `К` барабар.
65
+
2.`а` менен `а` барабар.
66
+
3.`н``л`ден чоңураак. Бул жерде салыштыруу бүтөт. Биринчи сап чоңураак.
67
67
68
68
```smart header="Not a real dictionary, but Unicode order"
69
69
The comparison algorithm given above is roughly equivalent to the one used in dictionaries or phone books, but it's not exactly the same.
@@ -207,7 +207,7 @@ Why did we go over these examples? Should we remember these peculiarities all th
207
207
- Treat any comparison with `undefined/null` except the strict equality `===` with exceptional care.
208
208
- Don't use comparisons `>= > < <=` with a variable which may be `null/undefined`, unless you're really sure of what you're doing. If a variable can have these values, check for them separately.
209
209
210
-
## Summary
210
+
## Корутунду
211
211
212
212
- Comparison operators return a boolean value.
213
213
- Strings are compared letter-by-letter in the "dictionary" order.
0 commit comments