Skip to content

Commit 363b06f

Browse files
authored
Merge pull request #17 from Salah856/master
translate comaprisons into arabic
2 parents d7b712c + 6e81c39 commit 363b06f

File tree

3 files changed

+98
-97
lines changed

3 files changed

+98
-97
lines changed

1-js/02-first-steps/09-comparison/1-comparison-questions/solution.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ null == "\n0\n" → false
1010
null === +"\n0\n"false
1111
```
1212

13-
Some of the reasons:
13+
بعض الأسباب:
1414

15-
1. Obviously, true.
16-
2. Dictionary comparison, hence false. `"a"` is smaller than `"p"`.
17-
3. Again, dictionary comparison, first char of `"2"` is greater than the first char of `"1"`.
18-
4. Values `null` and `undefined` equal each other only.
19-
5. Strict equality is strict. Different types from both sides lead to false.
20-
6. Similar to `(4)`, `null` only equals `undefined`.
21-
7. Strict equality of different types.
15+
1. من الواضح ، صحيح.
16+
2. مقارنة القاموس ، وبالتالي خطأ. "" a "أصغر من" "p" ".
17+
3. مرة أخرى ، مقارنة القاموس ، الحرف الأول من "2" أكبر من الحرف الأول من "1".
18+
4. القيم "فارغة" و "غير محددة" تساوي بعضها البعض فقط.
19+
5. المساواة الصارمة صارمة. أنواع مختلفة من كلا الجانبين تؤدي إلى خطأ.
20+
6- على غرار "(4)` ، "فارغ" يساوي فقط "غير محدد".
21+
7. المساواة الصارمة بمختلف أنواعها.

1-js/02-first-steps/09-comparison/1-comparison-questions/task.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
importance: 5
1+
درحة الأهمية: 5
22

33
---
44

5-
# Comparisons
5+
# المقارنات
66

7-
What will be the result for these expressions?
7+
ماذ ستكون نتيجة هذه التعبيرات؟
88

99
```js no-beautify
1010
5 > 4
Lines changed: 87 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,100 +1,99 @@
1-
# Comparisons
1+
#المقارنات
22

3-
We know many comparison operators from maths.
3+
نحن نعرف الكثير من معاملات المقارنة من الرياضيات
44

5-
In JavaScript they are written like this:
5+
: وفي لغة الجافسكريبت تكتب كما يلي
66

7-
- Greater/less than: <code>a &gt; b</code>, <code>a &lt; b</code>.
8-
- Greater/less than or equals: <code>a &gt;= b</code>, <code>a &lt;= b</code>.
9-
- Equals: `a == b`, please note the double equality sign `=` means the equality test, while a single one `a = b` means an assignment.
10-
- Not equals. In maths the notation is <code>&ne;</code>, but in JavaScript the it's written as <code>a != b</code>.
7+
- أكبر من وأصغر من: <code>a &gt; b</code>, <code>a &lt; b</code>.
8+
- أكبر : <code>a &gt;= b</code>, <code>a &lt;= b</code>.
9+
- يساوي: `a == b` ، يرجى ملاحظة أن علامة المساواة المزدوجة` = `تعني اختبار المساواة ، في حين أن كلمة واحدة` a = b` تعني تعيين أو مساواة .
10+
- لا تساوي. في الرياضيات ، يكون الترميز في JavaScript مكتوب مثل a !=b
1111

12-
In this article we'll learn more about different types of comparisons, how JavaScript makes them, including important peculiarities.
12+
في هذه المقالة سنتعلم المزيد عن الأنواع المختلفة من المقارنات ، وكيف تجعلها JavaScript ، بما في ذلك الخصائص المهمة.
1313

14-
## Boolean is the result
14+
## Boolean هي النتيجة
1515

16-
All comparison operators return a boolean value:
16+
تُرجع جميع عوامل المقارنة قيمة منطقية:
1717

18-
- `true` -- means "yes", "correct" or "the truth".
19-
- `false` -- means "no", "wrong" or "not the truth".
18+
- "صحيح" - يعني "نعم" أو "صحيح" أو "الحقيقة".
19+
- "false" - تعني "لا" أو "خطأ" أو "ليست الحقيقة".
2020

21-
For example:
21+
فمثلا:
2222

2323
```js run
2424
alert( 2 > 1 ); // true (correct)
2525
alert( 2 == 1 ); // false (wrong)
2626
alert( 2 != 1 ); // true (correct)
2727
```
2828

29-
A comparison result can be assigned to a variable, just like any value:
29+
يمكن تعيين نتيجة مقارنة لمتغير ، تمامًا مثل أي قيمة:
3030

3131
```js run
3232
let result = 5 > 4; // assign the result of the comparison
3333
alert( result ); // true
3434
```
3535

36-
## String comparison
36+
## مقارنة الكلمات
3737

38-
To see whether a string is greater than another, JavaScript uses the so-called "dictionary" or "lexicographical" order.
38+
لمعرفة ما إذا كانت السلسلة أكبر من غيرها ، تستخدم جافا سكريبت ما يسمى بترتيب "القاموس" أو "المعجم".
3939

40-
In other words, strings are compared letter-by-letter.
40+
بمعنى آخر ، تتم مقارنة السلاسل حرفًا بحرف.
4141

42-
For example:
42+
فمثلا:
4343

4444
```js run
4545
alert( 'Z' > 'A' ); // true
4646
alert( 'Glow' > 'Glee' ); // true
4747
alert( 'Bee' > 'Be' ); // true
4848
```
4949

50-
The algorithm to compare two strings is simple:
50+
خوارزمية مقارنة سلسلتين بسيطة:
5151

52-
1. Compare the first character of both strings.
53-
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.
54-
3. Otherwise, if both strings' first characters are the same, compare the second characters the same way.
55-
4. Repeat until the end of either string.
56-
5. If both strings end at the same length, then they are equal. Otherwise, the longer string is greater.
52+
1. قارن الحرف الأول من كلا السلاسل.
53+
2. إذا كان الحرف الأول من السلسلة الأولى أكبر (أو أقل) من السلسلة الأخرى ، فإن السلسلة الأولى أكبر (أو أقل) من السلسلة الثانية. لقد انتهينا.
54+
3. وبخلاف ذلك ، إذا كانت الأحرف الأولى لكلتا السلاسل متشابهة ، قارن الأحرف الثانية بنفس الطريقة.
55+
4. كرر حتى نهاية أي سلسلة.
56+
5. إذا انتهى كلا السلاسل بنفس الطول ، فإنهما متساويان. خلاف ذلك ، فإن السلسلة الأطول أكبر.
5757

58-
In the examples above, the comparison `'Z' > 'A'` gets to a result at the first step while the strings `"Glow"` and `"Glee"` are compared character-by-character:
58+
في الأمثلة أعلاه ، تصل المقارنة "Z"> "A" إلى نتيجة في الخطوة الأولى بينما تتم مقارنة السلاسل "" Glow "و" Glee "حرفًا بحرف:
5959

60-
1. `G` is the same as `G`.
61-
2. `l` is the same as `l`.
62-
3. `o` is greater than `e`. Stop here. The first string is greater.
60+
1. "G" هو نفسه "G".
61+
2- "l` هي نفس" l`.
62+
3. `o` أكبر من` e`. توقف هنا. السلسلة الأولى أكبر.
6363

64-
```smart header="Not a real dictionary, but Unicode order"
65-
The comparison algorithm given above is roughly equivalent to the one used in dictionaries or phone books, but it's not exactly the same.
64+
"` `عنوان ذكي ومختصر =" ليس قاموسًا حقيقيًا ، ولكن ترتيب Unicode "
65+
خوارزمية المقارنة الواردة أعلاه تكافئ تقريبًا تلك المستخدمة في القواميس أو دفاتر الهاتف ، ولكنها ليست هي نفسها تمامًا.
6666

67-
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>.
68-
```
67+
على سبيل المثال ، القضية مهمة. الحرف الكبير "A" لا يساوي الأحرف الصغيرة "a". أيهما أكبر؟ الأحرف الصغيرة "" أ "". لماذا ا؟ لأن الحرف الصغير يحتوي على فهرس أكبر في جدول الترميز الداخلي تستخدم JavaScript (Unicode). سنعود إلى تفاصيل محددة وعواقب ذلك في الفصل <info: string>.
68+
``
6969

70-
## Comparison of different types
70+
## مقارنة الأنواع المختلفة
7171

72-
When comparing values of different types, JavaScript converts the values to numbers.
72+
عند مقارنة قيم الأنواع المختلفة ، تحوّل JavaScript القيم إلى أرقام.
7373

74-
For example:
74+
فمثلا:
7575

7676
```js run
7777
alert( '2' > 1 ); // true, string '2' becomes a number 2
7878
alert( '01' == 1 ); // true, string '01' becomes a number 1
7979
```
8080

81-
For boolean values, `true` becomes `1` and `false` becomes `0`.
81+
بالنسبة إلى القيم المنطقية ، يصبح "true" "1" ويصبح "false" "0".
8282

83-
For example:
83+
فمثلا:
8484

8585
```js run
8686
alert( true == 1 ); // true
8787
alert( false == 0 ); // true
8888
```
8989

90-
````smart header="A funny consequence"
91-
It is possible that at the same time:
92-
93-
- Two values are equal.
94-
- One of them is `true` as a boolean and the other one is `false` as a boolean.
90+
"" عنوان ذكي ومختصر = "نتيجة مضحكة"
91+
من الممكن أنه في نفس الوقت:
9592

96-
For example:
93+
- قيمتان متساويتان.
94+
- واحد منهم "صحيح" باعتباره منطقيًا والآخر "خطأ" باعتباره منطقيًا.
9795

96+
فمثلا:
9897
```js run
9998
let a = 0;
10099
alert( Boolean(a) ); // false
@@ -105,109 +104,111 @@ alert( Boolean(b) ); // true
105104
alert(a == b); // true!
106105
```
107106

108-
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.
109-
````
110107

111-
## Strict equality
108+
هذه النتيجة طبيعية من وجهة نظر JavaScript. يؤدي التحقق من المساواة إلى تحويل القيم باستخدام التحويل الرقمي (وبالتالي يصبح "0" `يُصبح` 0`) ، بينما يستخدم التحويل الصريح `Boolean` مجموعة أخرى من القواعد.
109+
`` ``
110+
111+
## المساواة الصارمة
112+
113+
هناك مشكلة في التحقق المنتظم من المساواة `= =`. لا يمكن التمييز بين "0" و "false":
112114

113-
A regular equality check `==` has a problem. It cannot differentiate `0` from `false`:
114115

115116
```js run
116117
alert( 0 == false ); // true
117118
```
118119

119-
The same thing happens with an empty string:
120+
يحدث الشيء نفسه بسلسلة فارغة:
120121

121122
```js run
122123
alert( '' == false ); // true
123124
```
125+
يحدث هذا لأن المعاملات من أنواع مختلفة يتم تحويلها إلى أرقام من قبل عامل المساواة `==`. السلسلة الفارغة ، تمامًا مثل `false` ، تصبح صفرًا.
124126

125-
This happens because operands of different types are converted to numbers by the equality operator `==`. An empty string, just like `false`, becomes a zero.
126-
127-
What to do if we'd like to differentiate `0` from `false`?
127+
ماذا أفعل إذا أردنا التمييز بين "0" و "false"؟
128128

129-
**A strict equality operator `===` checks the equality without type conversion.**
129+
** عامل المساواة الصارم `= =` يتحقق من المساواة بدون تحويل النوع. **
130130

131-
In other words, if `a` and `b` are of different types, then `a === b` immediately returns `false` without an attempt to convert them.
131+
بمعنى آخر ، إذا كان "a" و "b" من أنواع مختلفة ، فإن "a === b" يُرجع على الفور "خطأ" دون محاولة تحويلها.
132132

133-
Let's try it:
133+
فلنجربها:
134134

135135
```js run
136136
alert( 0 === false ); // false, because the types are different
137137
```
138138

139-
There is also a "strict non-equality" operator `!==` analogous to `!=`.
139+
هناك أيضًا عامل "صارم لعدم المساواة" `! ==` مشابه لـ '! = `.
140140

141-
The strict equality operator is a bit longer to write, but makes it obvious what's going on and leaves less room for errors.
141+
عامل المساواة الصارم أطول قليلاً في الكتابة ، لكنه يوضح ما يحدث ويترك مساحة أقل للأخطاء.
142142

143-
## Comparison with null and undefined
143+
## مقارنة مع لا شيء وغير محدد
144144

145-
There's a non-intuitive behavior when `null` or `undefined` are compared to other values.
145+
هناك سلوك غير بديهي عند مقارنة "null" أو "undefined" بقيم أخرى.
146146

147-
For a strict equality check `===`
148-
: These values are different, because each of them is a different type.
147+
للتحقق من المساواة الصارمة `= =`
148+
: هذه القيم مختلفة ، لأن كل منها نوع مختلف.
149149

150150
```js run
151151
alert( null === undefined ); // false
152152
```
153153

154-
For a non-strict check `==`
155-
: There's a special rule. These two are a "sweet couple": they equal each other (in the sense of `==`), but not any other value.
154+
للتحقق غير الصارم `= =`
155+
: هناك قاعدة خاصة. هذان الزوجان "زوجان لطيفان": إنهما يساويان بعضهما البعض (بمعنى `= =`) ، ولكن ليس أي قيمة أخرى.
156156

157157
```js run
158158
alert( null == undefined ); // true
159159
```
160160

161-
For maths and other comparisons `< > <= >=`
162-
: `null/undefined` are converted to numbers: `null` becomes `0`, while `undefined` becomes `NaN`.
163161

164-
Now let's see some funny things that happen when we apply these rules. And, what's more important, how to not fall into a trap with them.
162+
بالنسبة للرياضيات والمقارنات الأخرى `<> <=> =`
163+
: "null / undefined" يتم تحويلها إلى أرقام: "null" تصبح "0" ، بينما "undefined" تصبح "NaN".
164+
165+
الآن دعونا نرى بعض الأشياء المضحكة التي تحدث عندما نطبق هذه القواعد. والأهم من ذلك ، كيف لا تقع في فخ معهم.
165166

166-
### Strange result: null vs 0
167+
### نتيجة غريبة: صفر مقابل 0
167168

168-
Let's compare `null` with a zero:
169+
دعنا نقارن `null` بصفر:
169170

170171
```js run
171172
alert( null > 0 ); // (1) false
172173
alert( null == 0 ); // (2) false
173174
alert( null >= 0 ); // (3) *!*true*/!*
174175
```
175176

176-
Mathematically, that's strange. The last result states that "`null` is greater than or equal to zero", so in one of the comparisons above it must be `true`, but they are both false.
177+
رياضيا ، هذا غريب. تشير النتيجة الأخيرة إلى أن "القيمة" فارغة "أكبر من الصفر أو تساويه" ، لذا في إحدى المقارنات أعلاه ، يجب أن تكون "true" ، لكن كلاهما خطأ.
177178

178-
The reason is that an equality check `==` and comparisons `> < >= <=` work differently. Comparisons convert `null` to a number, treating it as `0`. That's why (3) `null >= 0` is true and (1) `null > 0` is false.
179+
والسبب هو أن التحقق من المساواة `= =` والمقارنات `>> <> = <=` يعمل بشكل مختلف. تقوم المقارنات بتحويل `null` إلى رقم ، وتعاملها على أنها` 0`. لهذا السبب (3) `null> = 0` صحيحة و (1)` null> 0` خاطئة.
179180

180-
On the other hand, the equality check `==` for `undefined` and `null` is defined such that, without any conversions, they equal each other and don't equal anything else. That's why (2) `null == 0` is false.
181+
من ناحية أخرى ، يتم تحديد علامة المساواة `= =` لـ `undefined` و` null` بحيث لا يساوي أحدهما الآخر دون تحويلات ولا يساوي أي شيء آخر. لهذا السبب (2) `null == 0` خطأ.
181182

182-
### An incomparable undefined
183+
### غير المحدد غير المقارن
183184

184-
The value `undefined` shouldn't be compared to other values:
185+
لا يجب مقارنة القيمة `undefined` بالقيم الأخرى:
185186

186187
```js run
187188
alert( undefined > 0 ); // false (1)
188189
alert( undefined < 0 ); // false (2)
189190
alert( undefined == 0 ); // false (3)
190191
```
191192

192-
Why does it dislike zero so much? Always false!
193+
لماذا يكره الصفر كثيرا؟ دائما خطأ!
193194

194-
We get these results because:
195+
نحصل على هذه النتائج للأسباب التالية:
195196

196-
- Comparisons `(1)` and `(2)` return `false` because `undefined` gets converted to `NaN` and `NaN` is a special numeric value which returns `false` for all comparisons.
197-
- The equality check `(3)` returns `false` because `undefined` only equals `null`, `undefined`, and no other value.
197+
- المقارنات `(1)` و `(2)` إرجاع `false` لأنه يتم تحويل` undefined` إلى `NaN` و` NaN` هي قيمة رقمية خاصة تُرجع `false` لجميع المقارنات.
198+
- تحقق المساواة `((3)` تُرجع `false` لأن` undefined` تساوي فقط `null` و` undefined` ولا قيمة أخرى.
198199

199-
### Evade problems
200+
### تجنب المشاكل
200201

201-
Why did we go over these examples? Should we remember these peculiarities all the time? Well, not really. Actually, these tricky things will gradually become familiar over time, but there's a solid way to evade problems with them:
202+
لماذا راجعنا هذه الأمثلة؟ هل يجب أن نتذكر هذه الخصائص المميزة طوال الوقت؟ حسنًا ، ليس حقًا. في الواقع ، ستصبح هذه الأشياء الصعبة مألوفة تدريجيًا بمرور الوقت ، ولكن هناك طريقة صلبة للتهرب من المشاكل معها:
202203

203-
Just treat any comparison with `undefined/null` except the strict equality `===` with exceptional care.
204+
فقط تعامل مع أي مقارنة بـ "undefined / null" باستثناء المساواة الصارمة `===` مع رعاية استثنائية.
204205

205-
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.
206+
لا تستخدم المقارنات `> => <<=` مع متغير قد يكون `فارغًا / غير محدد` ، ما لم تكن متأكدًا حقًا مما تفعله. إذا كان المتغير يمكن أن يكون له هذه القيم ، تحقق منها بشكل منفصل.
206207

207-
## Summary
208+
## ملخص
208209

209-
- Comparison operators return a boolean value.
210-
- Strings are compared letter-by-letter in the "dictionary" order.
211-
- When values of different types are compared, they get converted to numbers (with the exclusion of a strict equality check).
212-
- The values `null` and `undefined` equal `==` each other and do not equal any other value.
213-
- Be careful when using comparisons like `>` or `<` with variables that can occasionally be `null/undefined`. Checking for `null/undefined` separately is a good idea.
210+
- ترجع عوامل المقارنة قيمة منطقية.
211+
- تتم مقارنة السلاسل حرفًا بحرف في ترتيب "القاموس".
212+
- عند مقارنة القيم من أنواع مختلفة ، يتم تحويلها إلى أرقام (باستثناء التحقق من المساواة الصارم).
213+
- القيمتان "null" و "undefined" تساوي `==` بعضها البعض ولا تساوي أي قيمة أخرى.
214+
- كن حذرًا عند استخدام مقارنات مثل `>` أو `<` مع المتغيرات التي يمكن أن تكون أحيانًا `خالية / غير محددة '. يُعد التحقق من "null / undefined" بشكل منفصل فكرة جيدة.

0 commit comments

Comments
 (0)