Skip to content

Commit e5a591f

Browse files
Merge pull request #2 from javascript-tutorial/master
Update
2 parents 43805f7 + b115a5d commit e5a591f

50 files changed

Lines changed: 1690 additions & 1665 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11

2-
Backticks embed the expression inside `${...}` into the string.
2+
Backticks تضمن التعبير داخل `${...}` في داخل النص.
33

44
```js run
55
let name = "Ilya";
66

7-
// the expression is a number 1
7+
// التعبير هو رقم 1
88
alert( `hello ${1}` ); // hello 1
99

10-
// the expression is a string "name"
10+
// التعبير هو نص "name"
1111
alert( `hello ${"name"}` ); // hello name
1212

13-
// the expression is a variable, embed it
13+
// التعبير هو متغير ، يتضمنه
1414
alert( `hello ${name}` ); // hello Ilya
1515
```

1-js/02-first-steps/05-types/1-string-quotes/task.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ importance: 5
44

55
# String quotes
66

7-
What is the output of the script?
7+
ما ناتج هذا الكود ؟
88

99
```js
1010
let name = "Ilya";

1-js/02-first-steps/05-types/article.md

Lines changed: 94 additions & 93 deletions
Large diffs are not rendered by default.

1-js/02-first-steps/06-alert-prompt-confirm/1-simple-page/solution.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ let name = prompt("What is your name?", "");
55
alert(name);
66
```
77

8-
The full page:
8+
الصفحة كاملة:
99

1010
```html
1111
<!DOCTYPE html>

1-js/02-first-steps/06-alert-prompt-confirm/1-simple-page/task.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ importance: 4
44

55
# A simple page
66

7-
Create a web-page that asks for a name and outputs it.
7+
قم بإنشاء صفحة ويب تسأل المستخدم لإدخال إسم ثم تظهره له.
88

99
[demo]
Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,44 @@
11
# Interaction: alert, prompt, confirm
22

3-
As we'll be using the browser as our demo environment, let's see a couple of functions to interact with the user: `alert`, `prompt` and `confirm`.
3+
بينما نستخدم المتصفح كبيئة تجريبية، تعال نرى بعض الدوال المستخدمة في التعامل مع المستخدم: `alert`و `prompt` و `confirm`.
44

55
## alert
66

7-
This one we've seen already. It shows a message and waits for the user to presses "OK".
7+
هذه رأيناها بالفعل. إنها تظهر رسالة وتنتظر من المستخدم أن يضغط على "OK".
88

9-
For example:
9+
على سبيل المثال:
1010

1111
```js run
1212
alert("Hello");
1313
```
1414

15-
The mini-window with the message is called a *modal window*. The word "modal" means that the visitor can't interact with the rest of the page, press other buttons, etc, until they have dealt with the window. In this case -- until they press "OK".
15+
النافذة الصغيرة التي تحتوي على رسالة تدعى *modal window*. الكلمة "modal" تعني أن المستخدم لا يستطيع أن يتفاعل مع باقي الصفحة، مثل الضغط على أزرار أخرى، إلخ، حتى يتعامل مع هذه النافذة. في هذه الحالة -- حتى يضغط على "OK".
1616

1717
## prompt
1818

19-
The function `prompt` accepts two arguments:
19+
الدالة `prompt` تقبل معاملين اثنين:
2020

2121
```js no-beautify
2222
result = prompt(title, [default]);
2323
```
2424

25-
It shows a modal window with a text message, an input field for the visitor, and the buttons OK/Cancel.
25+
إنها تظهر نافذة مشروطة برسالة نصية و حقل إدخال للزائر و وأزرار OK/Cancel.
2626

2727
`title`
28-
: The text to show the visitor.
28+
: النص الذي يظهر في الزائر.
2929

3030
`default`
31-
: An optional second parameter, the initial value for the input field.
31+
: معامل ثاني إختياري، القيمة الأولية لحقل الإدخال.
3232

3333
```smart header="The square brackets in syntax `[...]`"
34-
The square brackets around `default` in the syntax above denote that the parameter as optional, not required.
34+
الأقواس المربعة حول `default` في الكود أعلاه يوضح أن المعامل إختياري، ليس مطلوب.
3535
```
3636
37-
The visitor can type something in the prompt input field and press OK. Then we get that text in the `result`. Or they can cancel the input by pressing Cancel or hitting the `key:Esc` key, then we get `null` as the `result`.
37+
الزائر يستطيع كتابة أي شئ في حقل الإدخال ويضغط أوك. ثم نحصل على النص في `النتيجة`. أو يستطيع إلغاء الإدخال بالضغط على إلغاء أو الضغط على زرار `key:Esc` ، عندها سنحصل على `null` ك`result`.
3838
39-
The call to `prompt` returns the text from the input field or `null` if the input was canceled.
39+
إستدعاء `prompt` ترجع النص من حقل الإدخال أو `null` لو هذا الإدخال تم إلغاؤه.
4040
41-
For instance:
41+
على سبيل المثال:
4242
4343
```js run
4444
let age = prompt('How old are you?', 100);
@@ -47,15 +47,15 @@ alert(`You are ${age} years old!`); // You are 100 years old!
4747
```
4848

4949
````warn header="In IE: always supply a `default`"
50-
The second parameter is optional, but if we don't supply it, Internet Explorer will insert the text `"undefined"` into the prompt.
50+
المعامل الثاني إختياري، لكن إذا لم يتم إدخاله، انترنت اكسبلورر سيدخل النص `"undefined"` داخل حقل الإدخال.
5151

52-
Run this code in Internet Explorer to see:
52+
جرب هذا الكود في متصفح إنترنت إكسبلورر وسترى:
5353

5454
```js run
5555
let test = prompt("Test");
5656
```
5757

58-
So, for prompts to look good in IE, we recommend always providing the second argument:
58+
لذلك، ال prompts لكي تظهر بشكل جيد في انترنت اكسبلورر، ننصح دائما بتزويد المتصفح بالمعامل الثاني:
5959

6060
```js run
6161
let test = prompt("Test", ''); // <-- for IE
@@ -64,42 +64,42 @@ let test = prompt("Test", ''); // <-- for IE
6464
6565
## confirm
6666
67-
The syntax:
67+
الكود:
6868
6969
```js
7070
result = confirm(question);
7171
```
7272
73-
The function `confirm` shows a modal window with a `question` and two buttons: OK and Cancel.
73+
الدالة `confirm` تظهر نافذة مشروطة ب `سؤال` و زرارين: OK and Cancel.
7474
75-
The result is `true` if OK is pressed and `false` otherwise.
75+
النتيجة هي `true` لو تم الضغط على زر أوك أو`false` لغير ذلك.
7676
77-
For example:
77+
على سبيل المثال:
7878
7979
```js run
8080
let isBoss = confirm("Are you the boss?");
8181
82-
alert( isBoss ); // true if OK is pressed
82+
alert( isBoss ); // true لو زر أوك تم الضغط عليه
8383
```
8484
8585
## Summary
8686
87-
We covered 3 browser-specific functions to interact with visitors:
87+
غطينا 3 دوال خاصة بالمتصفح للتعامل مع الزوار:
8888
8989
`alert`
90-
: shows a message.
90+
: يظهر رسالة.
9191
9292
`prompt`
93-
: shows a message asking the user to input text. It returns the text or, if Cancel button or `key:Esc` is clicked, `null`.
93+
: يظهر رسالة تسال المستخدم لإدخال نص. يتم إرجاع النص ، أو زر إلغاء أو زر `key:Esc` تم الضغط عليه، أو `null`.
9494
9595
`confirm`
96-
: shows a message and waits for the user to press "OK" or "Cancel". It returns `true` for OK and `false` for Cancel/`key:Esc`.
96+
: تظهر رسالة وتنتظر المستخدم ليضغط على زر "OK" أو "Cancel". ترجع `true` في حالة أوك و `false` في حالة Cancel/`key:Esc`.
9797
98-
All these methods are modal: they pause script execution and don't allow the visitor to interact with the rest of the page until the window has been dismissed.
98+
كل هذه الطرق مشروطة: إنها توقف تنفيذ الكود ولا تسمح للزائر للتعامل مع باقي الصفحة حتى يتم صرف النافذة .
9999
100-
There are two limitations shared by all the methods above:
100+
يوجد قيدان مشتركان لكل الطرق أعلاه :
101101
102-
1. The exact location of the modal window is determined by the browser. Usually, it's in the center.
103-
2. The exact look of the window also depends on the browser. We can't modify it.
102+
1. الموقع المضبوط للنافذة المشروطة يتم تقريره من خلال المتصفح. عادة، إنها تكون في المنتصف.
103+
2. الشكل المضبوط للنافذة أيضاً يعتمد على المتصفح . لا نستطيع تعديله.
104104
105-
That is the price for simplicity. There are other ways to show nicer windows and richer interaction with the visitor, but if "bells and whistles" do not matter much, these methods work just fine.
105+
هذا ثمن البساطة. هناك طرق أخرى تظهر نوافذ ألطف و أغنى في التعامل مع المستخدم، لكن لو "الأجراس و الصفارات" لا تهم كثيراً، هذه الطرق تعمل بشكل جيد.
Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,102 +1,102 @@
11
# Type Conversions
22

3-
Most of the time, operators and functions automatically convert the values given to them to the right type.
3+
معظم الوقت، المعاملات و الدوال تحول أوتوماتيكياً تحول القيم المعطاة لهم للنوع الصحيح.
44

5-
For example, `alert` automatically converts any value to a string to show it. Mathematical operations convert values to numbers.
5+
على سبيل المثال ، `alert` تحول أوتوماتيكياً أي قيمة إلى نص لإظهاره. المعاملات الرياضية تحول القيم إلى أرقام.
66

7-
There are also cases when we need to explicitly convert a value to the expected type.
7+
هناك أيضاً حالات نحتاج إلى تصريح تحويل القيمة إلى النوع المطلوبة .
88

99
```smart header="Not talking about objects yet"
10-
In this chapter, we won't cover objects. For now we'll just be talking about primitives.
10+
في هذا الفصل ، لن نغطي الكائنات. الأن سوف نتحدث عن الأنواع الأساسية.
1111
12-
Later, after we learn about objects, in the chapter <info:object-toprimitive> we'll see how objects fit in.
12+
فيما بعد ، بعد أن نتعلم عن الكائنات، في هذا الفصل <info:object-toprimitive> سنرى كيف الكائنات تتلائم فيه.
1313
```
1414

1515
## String Conversion
1616

17-
String conversion happens when we need the string form of a value.
17+
التحويل إلى نص يحدث عندما نحتاج الصورة النصية للقيمة.
1818

19-
For example, `alert(value)` does it to show the value.
19+
على سبيل المثال ، `alert(value)` تفعل ذلك لإظهار القيمة.
2020

21-
We can also call the `String(value)` function to convert a value to a string:
21+
نستطيع أيضاً إستدعاء دالة `String(value)` لكي نحول القيمة إلى نص:
2222

2323
```js run
2424
let value = true;
2525
alert(typeof value); // boolean
2626

2727
*!*
28-
value = String(value); // now value is a string "true"
28+
value = String(value); // الأن القيمة هي نص تساوي "true"
2929
alert(typeof value); // string
3030
*/!*
3131
```
3232

33-
String conversion is mostly obvious. A `false` becomes `"false"`, `null` becomes `"null"`, etc.
33+
التحويل إلى نص واضح جداً. `false` تصبح `"false"`و `null` تصبح `"null"`، إلخ.
3434

3535
## Numeric Conversion
3636

37-
Numeric conversion happens in mathematical functions and expressions automatically.
37+
التحويل إلى رقم يتم أوتوماتيكياً في المعاملات والتعبيرات الرياضية.
3838

39-
For example, when division `/` is applied to non-numbers:
39+
على سبيل المثال ، في حالة القسمة `/` عندما يتم تطبيقها على نوع غير رقمي:
4040

4141
```js run
42-
alert( "6" / "2" ); // 3, strings are converted to numbers
42+
alert( "6" / "2" ); // 3، النصوص تتحول إلى أرقام
4343
```
4444

45-
We can use the `Number(value)` function to explicitly convert a `value` to a number:
45+
نستطيع إستخدام دالة `Number(value)` للتصريح بتحويل القيمة `value` إلى رقم:
4646

4747
```js run
4848
let str = "123";
4949
alert(typeof str); // string
5050

51-
let num = Number(str); // becomes a number 123
51+
let num = Number(str); // تصبح رقم 123
5252

5353
alert(typeof num); // number
5454
```
5555

56-
Explicit conversion is usually required when we read a value from a string-based source like a text form but expect a number to be entered.
56+
تصريح التحويل عادة يكون مطلوب عندما نقرأ قيمة من مصدر يعتمد على النص مثل حقل إدخال في نموذج لكن نتوقع أن يتم إدخال رقم .
5757

58-
If the string is not a valid number, the result of such a conversion is `NaN`. For instance:
58+
لو النص ليس رقم صالح، ستكون النتيجة لمثل هذا التحويل هي `NaN`. على سبيل المثال:
5959

6060
```js run
6161
let age = Number("an arbitrary string instead of a number");
6262

63-
alert(age); // NaN, conversion failed
63+
alert(age); // NaN، التحويل فشل
6464
```
6565

66-
Numeric conversion rules:
66+
قواعد التحويل الرقمي:
6767

68-
| Value | Becomes... |
68+
| القيمة | تصبح... |
6969
|-------|-------------|
7070
|`undefined`|`NaN`|
7171
|`null`|`0`|
7272
|<code>true&nbsp;and&nbsp;false</code> | `1` and `0` |
73-
| `string` | Whitespaces from the start and end are removed. If the remaining string is empty, the result is `0`. Otherwise, the number is "read" from the string. An error gives `NaN`. |
73+
| `string` | المساحات البيضاء في البداية والنهاية يتم إزالتها. لو باقي النص فارغ ، النتيجة هي `0`. غير ذلك، الرقم "يتم قرائته" من النص. أي خطأ يعطي`NaN`. |
7474

75-
Examples:
75+
أمثلة:
7676

7777
```js run
7878
alert( Number(" 123 ") ); // 123
79-
alert( Number("123z") ); // NaN (error reading a number at "z")
79+
alert( Number("123z") ); // NaN (خطأ في قراءة الرقم عند "z")
8080
alert( Number(true) ); // 1
8181
alert( Number(false) ); // 0
8282
```
8383

84-
Please note that `null` and `undefined` behave differently here: `null` becomes zero while `undefined` becomes `NaN`.
84+
من فضلك لاحظ أن `null` و `undefined` تسلك سلوك مختلف هنا: `null` تصبح صفر بينما `undefined` تصبح `NaN`.
8585

86-
Most mathematical operators also perform such conversion, we'll see that in the next chapter.
86+
معظم المعاملات الرياضية أيضا تعمل مثل هذا التحويل ، سوف نرى ذلك في الفصل القادم .
8787

8888
## Boolean Conversion
8989

90-
Boolean conversion is the simplest one.
90+
التحويل إلى قيم منطقية هو الأبسط.
9191

92-
It happens in logical operations (later we'll meet condition tests and other similar things) but can also be performed explicitly with a call to `Boolean(value)`.
92+
إنه يحدث في معاملات منطقية (فيما بعد سنقابل إختبارات مشروطة وأشياء أخرى مشابهة ) لكن أيضاً يمكن تنفيذها تصريحياً عن طريق إستدعاء `Boolean(value)`.
9393

94-
The conversion rule:
94+
قاعدة التحويل:
9595

96-
- Values that are intuitively "empty", like `0`, an empty string, `null`, `undefined`, and `NaN`, become `false`.
97-
- Other values become `true`.
96+
- القيم التي تكون حدسية "فارغة"، مثل `0`و نص فارغ و `null`و `undefined`و `NaN`تصبح `false`.
97+
- كل القيم الأخرى تصبح `true`.
9898

99-
For instance:
99+
على سبيل المثال:
100100

101101
```js run
102102
alert( Boolean(1) ); // true
@@ -106,45 +106,45 @@ alert( Boolean("hello") ); // true
106106
alert( Boolean("") ); // false
107107
```
108108

109-
````warn header="Please note: the string with zero `\"0\"` is `true`"
110-
Some languages (namely PHP) treat `"0"` as `false`. But in JavaScript, a non-empty string is always `true`.
109+
````warn header="من فضلك لاحظ: النص المكون من صفر `\"0\"` يكون `true`"
110+
بعض اللغات (أعني PHP) تعامل `"0"` ك `false`. لكن في الجافا سكربت ، النص غير الفارغ دائماً `true`.
111111

112112
```js run
113113
alert( Boolean("0") ); // true
114-
alert( Boolean(" ") ); // spaces, also true (any non-empty string is true)
114+
alert( Boolean(" ") ); // المسافات، أيضاً true (أي نص غير فارغ يكون true)
115115
```
116116
````
117117
118118
## Summary
119119
120-
The three most widely used type conversions are to string, to number, and to boolean.
120+
تحويلات الأنواع الثلاثة الأكثر إستخداماً هي إلى نص ، إلى رقم ، إلى قيمة منطقية .
121121
122-
**`String Conversion`** -- Occurs when we output something. Can be performed with `String(value)`. The conversion to string is usually obvious for primitive values.
122+
**`التحويل للنص`** -- يحدث عندما نظهر شئ. يمكن تنفيذه عن طريق `String(value)`. التحويل إلى نص عادة واضح للقيم البسيطة .
123123
124-
**`Numeric Conversion`** -- Occurs in math operations. Can be performed with `Number(value)`.
124+
**`التحويل إلى رقم`** -- يحدث في المعاملات الرياضية. يمكن تنفيذها عن طريق `Number(value)`.
125125
126-
The conversion follows the rules:
126+
التحويل يتبع القواعد:
127127
128-
| Value | Becomes... |
128+
| القيمة | تصبح... |
129129
|-------|-------------|
130130
|`undefined`|`NaN`|
131131
|`null`|`0`|
132132
|<code>true&nbsp;/&nbsp;false</code> | `1 / 0` |
133-
| `string` | The string is read "as is", whitespaces from both sides are ignored. An empty string becomes `0`. An error gives `NaN`. |
133+
| `string` | يتم قراءة النص "كما هو"،المسافات البيضاء من الجانبين يتم تجاهلها. النص الفارغ يصبح `0`. الخطأ `NaN`. |
134134
135-
**`Boolean Conversion`** -- Occurs in logical operations. Can be performed with `Boolean(value)`.
135+
**`التحويلات المنطقية`** -- يحدث في المعاملات المنطقية. يتم تنفيذه عن طريق `Boolean(value)`.
136136
137-
Follows the rules:
137+
يتبع القواعد الأتية:
138138
139-
| Value | Becomes... |
139+
| القيمة | تصبح... |
140140
|-------|-------------|
141141
|`0`, `null`, `undefined`, `NaN`, `""` |`false`|
142-
|any other value| `true` |
142+
|أي قيمة أخرى| `true` |
143143
144144
145-
Most of these rules are easy to understand and memorize. The notable exceptions where people usually make mistakes are:
145+
معظم هذه القواعد سهل فهمها وحفظها. الإستثناءات الملحوظة عندما يفعل الناس عادة أخطاء وهي :
146146
147-
- `undefined` is `NaN` as a number, not `0`.
148-
- `"0"` and space-only strings like `" "` are true as a boolean.
147+
- `undefined` تكون `NaN` كرقم ليست `0`.
148+
- `"0"` والنصوص التي تحتوي على مسافات فقط `" "` هي true كقيمة منطقية.
149149
150-
Objects aren't covered here. We'll return to them later in the chapter <info:object-toprimitive> that is devoted exclusively to objects after we learn more basic things about JavaScript.
150+
لم يتم تغطية الكائنات هنا. سنعود إليهم لاحقاً في هذا الفصل <info:object-toprimitive> تكون مكرسة حصرياً للكائنات بعد أن تعمل أشياء أساسية أكثر عن الجافا سكربت .

1-js/02-first-steps/10-ifelse/5-rewrite-if-question/task.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44

55
# قم بتحويل 'if' إلى '?'
66

7-
قم بإعادة كتابة `if` باستخدام معامل الشرط `'?'`:
7+
قم بإعادة كتابة `if` باستخدام عامل الشرط `'?'`:
88

99
```js
1010
let result;
1111

1212
if (a + b < 4) {
13-
result = 'تحت';
13+
result = "تحت";
1414
} else {
15-
result = 'فوق';
15+
result = "فوق";
1616
}
1717
```

0 commit comments

Comments
 (0)