Skip to content

Commit 1e3c557

Browse files
authored
Merge pull request #1 from javascript-tutorial/master
copy master
2 parents 01e6e59 + d08c788 commit 1e3c557

60 files changed

Lines changed: 1572 additions & 1530 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: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,46 @@
1-
# Code editors
1+
# محررات الأكواد
22

3-
A code editor is the place where programmers spend most of their time.
3+
محرر الأكواد هو المكان الذي يقضي فيه المبرمجون معظم وقتهم.
44

5-
There are two main types of code editors: IDEs and lightweight editors. Many people use one tool of each type.
5+
يوجد نوعين من محررات الأكواد: IDEs ( بيئة التطوير الكاملة)و المحررات البسيطة. العديد من الناس يستخدمون أداة واحدة لكل نوع.
66

77
## IDE
88

9-
The term [IDE](https://en.wikipedia.org/wiki/Integrated_development_environment) (Integrated Development Environment) refers to a powerful editor with many features that usually operates on a "whole project." As the name suggests, it's not just an editor, but a full-scale "development environment."
9+
مصطلح [IDE](https://en.wikipedia.org/wiki/Integrated_development_environment) (Integrated Development Environment) يشير إلى محرر بإمكانات هائلة، مع العديد من المميزات التي تعمل عادة على " مشروع كامل". كما يوحي الاسم، فهو ليس مجرد محرر أكواد، ولكنه "بيئة تطوير" واسعة النطاق.
1010

11-
An IDE loads the project (which can be many files), allows navigation between files, provides autocompletion based on the whole project (not just the open file), and integrates with a version management system (like [git](https://git-scm.com/)), a testing environment, and other "project-level" stuff.
11+
IDE تقوم بتحميل المشروع ) الذي يمكن أن يتكون من العديد من الملفات)، ويسمح بالتنقل بين الملفات، ويوفر خاصة الإكمال التلقائي المعتمدة على المشروع ككل ( وليس الملف المفتوح فقط) , كما أنه يمكن أن يرتبط مع أنظمة إدارة الإصدار (مثل [git](https://git-scm.com/)), وبيئة الاختبار, وغيرها من الأشياء على مستوى المشروع.
1212

13-
If you haven't selected an IDE yet, consider the following options:
13+
إذا لم تقم باختيار IDE بعد ، ففكر في الخيارات التالية:
1414

15-
- [Visual Studio Code](https://code.visualstudio.com/) (cross-platform, free).
16-
- [WebStorm](http://www.jetbrains.com/webstorm/) (cross-platform, paid).
15+
- [فيجوال ستديو كود](https://code.visualstudio.com/) (يعمل على أكثر من نظام تشغيل, مجاني).
16+
- [ويب ستورم](http://www.jetbrains.com/webstorm/) (يعمل على أكثر من نظام تشغيل, مدفوع).
1717

18-
For Windows, there's also "Visual Studio", not to be confused with "Visual Studio Code". "Visual Studio" is a paid and mighty Windows-only editor, well-suited for the .NET platform. It's also good at JavaScript. There's also a free version [Visual Studio Community](https://www.visualstudio.com/vs/community/).
18+
بالنسبة للويندوز، يمكن استخدام برنامج فيجوال ستديو، لايجب الخلط بينه وبين الفيجوال ستديو كود، فيجوال ستديو هو محرر مدفوع يعمل على نظام ويندوز فقك، ومناسب تماماً لبيئة الدوت نت. أنه أيضاً جيد للجافاسكريبت. كما يوجد إصدار مجاني منه [Visual Studio Community](https://www.visualstudio.com/vs/community/).
1919

20-
Many IDEs are paid, but have a trial period. Their cost is usually negligible compared to a qualified developer's salary, so just choose the best one for you.
20+
.عادة ما تكون تكلفتها ضئيلة للغاية مقارنة براتب المطور المؤهل ، لذلك فقط اختر الأفضل بالنسبة لك.العديد من بيئات التطوير مدفوعة، لكن لها فترة سماحية
2121

22-
## Lightweight editors
22+
## المحررات البسيطة
2323

24-
"Lightweight editors" are not as powerful as IDEs, but they're fast, elegant and simple.
24+
المحررات البسيطة" ليست بقوة ال" IDEs لكنها سريعة, وأنيقة وبسيطة
2525

26-
They are mainly used to open and edit a file instantly.
26+
يتم استخدامها بشكل رئيسي لفتح وتحرير ملف على الفور.
2727

28-
The main difference between a "lightweight editor" and an "IDE" is that an IDE works on a project-level, so it loads much more data on start, analyzes the project structure if needed and so on. A lightweight editor is much faster if we need only one file.
28+
الفارق الرئيسي بين المحررات البسيطة و "بيئة التطوير" هو أن بيئة التطوير تعمل على مستوى المشروع، لذلك فإنها تقوم بتحميل المزيد من البيانات عند البدء، وتحليل هيكل المشروع إذا لزم ذلك. أما المحررات البسيطة فإنها أسرع في حال نريد ملف واحد فقط.
2929

30-
In practice, lightweight editors may have a lot of plugins including directory-level syntax analyzers and autocompleters, so there's no strict border between a lightweight editor and an IDE.
30+
من الناحية العملية ، قد تحتوي المحررات البسيطة على الكثير من المكونات الإضافية بما في ذلك محللات بناء الجملة على مستوى الدليل وأجهزة الإكمال التلقائي ، لذلك لا توجد حدود صارمة بين المحرر البسيط و IDE.
3131

32-
The following options deserve your attention:
32+
الخيارات التالية تستحق انتباهك:
3333

34-
- [Atom](https://atom.io/) (cross-platform, free).
35-
- [Visual Studio Code](https://code.visualstudio.com/) (cross-platform, free).
36-
- [Sublime Text](http://www.sublimetext.com) (cross-platform, shareware).
37-
- [Notepad++](https://notepad-plus-plus.org/) (Windows, free).
38-
- [Vim](http://www.vim.org/) and [Emacs](https://www.gnu.org/software/emacs/) are also cool if you know how to use them.
34+
- [Atom](https://atom.io/) (يعمل على العديد من أنظمة التشغيل, مجاني).
35+
- [Visual Studio Code](https://code.visualstudio.com/) (يعمل على العديد من أنظمة التشغيل, مجاني).
36+
- [Sublime Text](http://www.sublimetext.com) (يعمل على العديد من أنظمة التشغيل, برنامج مشاركة).
37+
- [Notepad++](https://notepad-plus-plus.org/) (الويندوز, مجاني).
38+
- [Vim](http://www.vim.org/) و [Emacs](https://www.gnu.org/software/emacs/) رائعة إذا كنت تعرف كيفية استخدامها.
3939

40-
## Let's not argue
40+
## دعونا لانتشاجر
4141

42-
The editors in the lists above are those that either I or my friends whom I consider good developers have been using for a long time and are happy with.
42+
المحررات التي بالقائمة الأعلى هي التي نقوم باستخدامها أنا وأصدقائي، والذين أعتقد أنهم مطورون جيدون يستخدمونها منذ وقت طويل وتسعدهم.
4343

44-
There are other great editors in our big world. Please choose the one you like the most.
44+
يوجد أيضاً محررات رائعة في عالمنا الكبير، الرجاء اختيار المحرر الذي تفضله.
4545

46-
The choice of an editor, like any other tool, is individual and depends on your projects, habits, and personal preferences.
46+
اختيار المحرر، مثل أي أداة أخرى، هو اختيار فردي ويعتمد على مشروعاتك، وعاداتك، وتفضيلاتك الشخصية.
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
To precisely match the functionality of `switch`, the `if` must use a strict comparison `'==='`.
1+
للوصول إلى وظيفة `switch` باستخدام `if` يجب استخدام معامل التساوي الثلاثي `'==='`.
22

3-
For given strings though, a simple `'=='` works too.
3+
بالنسبة للنصوص فإن `'=='` ستعمل أيضًا.
44

55
```js no-beautify
66
if(browser == 'Edge') {
7-
alert("You've got the Edge!");
7+
alert( "لديك Edge!" );
88
} else if (browser == 'Chrome'
99
|| browser == 'Firefox'
1010
|| browser == 'Safari'
1111
|| browser == 'Opera') {
12-
alert( 'Okay we support these browsers too' );
12+
alert( 'حسنا نحن ندعم هذه المتصفحات أيضًا' );
1313
} else {
14-
alert( 'We hope that this page looks ok!' );
14+
alert( 'نتمنى أن تكون هذه الصفحة معروضة بشكل جيد' );
1515
}
1616
```
1717

18-
Please note: the construct `browser == 'Chrome' || browser == 'Firefox' …` is split into multiple lines for better readability.
18+
تم فصل `browser == 'Chrome' || browser == 'Firefox' …` إلى عدة سطور لسهولة القراءة.
1919

20-
But the `switch` construct is still cleaner and more descriptive.
20+
لكن استخدام `switch` ما زال أفضل.
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
importance: 5
1+
الأهمية: 5
22

33
---
44

5-
# Rewrite the "switch" into an "if"
5+
# أعد كتابة "switch" باستخدام "if"
66

7-
Write the code using `if..else` which would correspond to the following `switch`:
7+
أكتب برنامج باستخدام `if..else` يطابق جملة `switch` التالية:
88

99
```js
1010
switch (browser) {
1111
case 'Edge':
12-
alert( "You've got the Edge!" );
12+
alert( "لديك Edge!" );
1313
break;
1414

1515
case 'Chrome':
1616
case 'Firefox':
1717
case 'Safari':
1818
case 'Opera':
19-
alert( 'Okay we support these browsers too' );
19+
alert( 'حسنا نحن ندعم هذه المتصفحات أيضًا' );
2020
break;
2121

2222
default:
23-
alert( 'We hope that this page looks ok!' );
23+
alert( 'نتمنى أن تكون هذه الصفحة معروضة بشكل جيد' );
2424
}
2525
```
2626

1-js/02-first-steps/14-switch/2-rewrite-if-switch/solution.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
The first two checks turn into two `case`. The third check is split into two cases:
1+
أول شرطين يتحولان إلى أثنان `case`. الشرط الثالث يتحول إلى حالتين:
22

33
```js run
44
let a = +prompt('a?', '');
@@ -21,6 +21,6 @@ switch (a) {
2121
}
2222
```
2323

24-
Please note: the `break` at the bottom is not required. But we put it to make the code future-proof.
24+
لاحظ أن `break` في النهاية ليست مطلوبة ولكن تم وضعها تحسبًا للمستقبل.
2525

26-
In the future, there is a chance that we'd want to add one more `case`, for example `case 4`. And if we forget to add a break before it, at the end of `case 3`, there will be an error. So that's a kind of self-insurance.
26+
ربما نريد لاحقًا إضافة المزيد من `case` على سبيل المثال `case 4`. وإذا نسينا وضع break في نهاية `case 3` سيكون هناك خطأ.

1-js/02-first-steps/14-switch/2-rewrite-if-switch/task.md

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

33
---
44

5-
# Rewrite "if" into "switch"
5+
# حول "if" إلى "switch"
66

7-
Rewrite the code below using a single `switch` statement:
7+
أعد كتابة البرنامج التالي باستخدام `switch`:
88

99
```js run
1010
let a = +prompt('a?', '');
Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
# The "switch" statement
1+
# جملة "switch"
22

3-
A `switch` statement can replace multiple `if` checks.
3+
جملة `switch` يمكنها استبدال العديد من جمل `if.
44

5-
It gives a more descriptive way to compare a value with multiple variants.
5+
تعطي طريقة أفضل لمقارنة متغير مقابل مجموعة من القيم.
66

7-
## The syntax
7+
## طريقة الكتابة
88

9-
The `switch` has one or more `case` blocks and an optional default.
9+
جملة `switch` تحتوي على `case` واحدة أو أكثر وحالة إفتراضية إختيارية.
1010

11-
It looks like this:
11+
مثل هذا:
1212

1313
```js no-beautify
1414
switch(x) {
@@ -26,71 +26,71 @@ switch(x) {
2626
}
2727
```
2828

29-
- The value of `x` is checked for a strict equality to the value from the first `case` (that is, `value1`) then to the second (`value2`) and so on.
30-
- If the equality is found, `switch` starts to execute the code starting from the corresponding `case`, until the nearest `break` (or until the end of `switch`).
31-
- If no case is matched then the `default` code is executed (if it exists).
29+
- قيمة `x` يتم إختبار تساويها مع أول `case` (`value1`) ثم تتنتقل إلى (`value2`) وهكذا.
30+
- إذا وجد تساوي تبدأ `switch` بتنفيذ الكود ابتداءًا من هذه ال `case` حتى أقرب `break` (أو نهاية `switch`).
31+
- إذا لم تطابق أي حالة يتم تنفيذ الكود بداخل `default` إذا وجدت.
3232

33-
## An example
33+
## مثال
3434

35-
An example of `switch` (the executed code is highlighted):
35+
مثال على `switch` (تم نحديد الكود الذي سينفذ):
3636

3737
```js run
3838
let a = 2 + 2;
3939

4040
switch (a) {
4141
case 3:
42-
alert( 'Too small' );
42+
alert( 'قليل جدًا' );
4343
break;
4444
*!*
4545
case 4:
46-
alert( 'Exactly!' );
46+
alert( 'تمامًا!' );
4747
break;
4848
*/!*
4949
case 5:
50-
alert( 'Too large' );
50+
alert( 'كثير جدًا' );
5151
break;
5252
default:
53-
alert( "I don't know such values" );
53+
alert( "لا أعرف هذه القيمة" );
5454
}
5555
```
5656

57-
Here the `switch` starts to compare `a` from the first `case` variant that is `3`. The match fails.
57+
تبدأ `switch` بمقارنة قيمة `a` بدايةً من أول `case` التي هي `3`. لا تطابق.
5858

59-
Then `4`. That's a match, so the execution starts from `case 4` until the nearest `break`.
59+
ثم `4`. وهنا يحدث تطابق ويبدأ التنفيذ من `case 4` حتى أقرب `break`.
6060

61-
**If there is no `break` then the execution continues with the next `case` without any checks.**
61+
**إذا لم يوجد `break` يستمر تنفيذ `case` التالية بدون فحص الشرط.**
6262

63-
An example without `break`:
63+
مثال بدون `break`:
6464

6565
```js run
6666
let a = 2 + 2;
6767

6868
switch (a) {
6969
case 3:
70-
alert( 'Too small' );
70+
alert( 'قليل جدًا' );
7171
*!*
7272
case 4:
73-
alert( 'Exactly!' );
73+
alert( 'تمامًا!' );
7474
case 5:
75-
alert( 'Too big' );
75+
alert( 'كثير جدًا' );
7676
default:
77-
alert( "I don't know such values" );
77+
alert( "لا أعرف هذه القيمة" );
7878
*/!*
7979
}
8080
```
8181

82-
In the example above we'll see sequential execution of three `alert`s:
82+
في هذا المثال سيتم تنفيذ ثلاثة أوامر `alert`:
8383

8484
```js
85-
alert( 'Exactly!' );
86-
alert( 'Too big' );
87-
alert( "I don't know such values" );
85+
alert( 'تمامًا!' );
86+
alert( 'كثير جدًا' );
87+
alert( "لا أعرف هذه القيمة" );
8888
```
8989

90-
````smart header="Any expression can be a `switch/case` argument"
91-
Both `switch` and `case` allow arbitrary expressions.
90+
````smart header="يمكن استخدام أي تعبير بداخل `switch/case`"
91+
إن `switch` و `case` يسمحان باستخدام التعبيرات.
9292

93-
For example:
93+
مثال:
9494

9595
```js run
9696
let a = "1";
@@ -99,74 +99,74 @@ let b = 0;
9999
switch (+a) {
100100
*!*
101101
case b + 1:
102-
alert("this runs, because +a is 1, exactly equals b+1");
102+
alert("سيتم تنفيذ هذا لأن +a هو 1 ويساوي تمامًا b+1");
103103
break;
104104
*/!*
105105

106106
default:
107-
alert("this doesn't run");
107+
alert("لن يتم تنفيذ هذا");
108108
}
109109
```
110-
Here `+a` gives `1`, that's compared with `b + 1` in `case`, and the corresponding code is executed.
110+
هنا `+a` تعطي `1` ويتم مقارنتها مع `b + 1` في `case` وينفذ الكود.
111111
````
112112
113-
## Grouping of "case"
113+
## تجميع "case"
114114
115-
Several variants of `case` which share the same code can be grouped.
115+
يمكن تجميع العديد من `case` التي تتشارك في نفس الأوامر.
116116
117-
For example, if we want the same code to run for `case 3` and `case 5`:
117+
مثلًا إذا أردنا تنفيذ نفس الأوامر في `case 3` و `case 5`:
118118
119119
```js run no-beautify
120120
let a = 3;
121121
122122
switch (a) {
123123
case 4:
124-
alert('Right!');
124+
alert('صحيح!');
125125
break;
126126
127127
*!*
128-
case 3: // (*) grouped two cases
128+
case 3: // (*) تجميع حالتين
129129
case 5:
130-
alert('Wrong!');
131-
alert("Why don't you take a math class?");
130+
alert('خطأ!');
131+
alert("لماذا لا تأخذ روس في الرياضيات ؟");
132132
break;
133133
*/!*
134134
135135
default:
136-
alert('The result is strange. Really.');
136+
alert('النتيجة غريبة حقًا.');
137137
}
138138
```
139139
140-
Now both `3` and `5` show the same message.
140+
الآن كل من `3` و `5` يظهرون الرسالة.
141141
142-
The ability to "group" cases is a side-effect of how `switch/case` works without `break`. Here the execution of `case 3` starts from the line `(*)` and goes through `case 5`, because there's no `break`.
142+
إمكانية تجميع الحالات هي تأثير جانبي لطريقة عمل `switch/case` بدون `break`. هنا يبدأ التنفيذ من `case 3` في السطر `(*)` وينتقل إلى `case 5` لعدم وجود `break`.
143143
144-
## Type matters
144+
## الأنواع مهمة
145145
146-
Let's emphasize that the equality check is always strict. The values must be of the same type to match.
146+
عملية التساوي هي عملية حادة فيجب أن تكون القيم من نفس النوع ليتم التطابق.
147147
148-
For example, let's consider the code:
148+
على سبيل المثال لنأخذ البرنامج التالي:
149149
150150
```js run
151-
let arg = prompt("Enter a value?");
151+
let arg = prompt("أكتب قيمة ؟");
152152
switch (arg) {
153153
case '0':
154154
case '1':
155-
alert( 'One or zero' );
155+
alert( 'صفر أو واحد' );
156156
break;
157157
158158
case '2':
159-
alert( 'Two' );
159+
alert( 'أثنان' );
160160
break;
161161
162162
case 3:
163-
alert( 'Never executes!' );
163+
alert( 'لن ينفذ أبدًا!' );
164164
break;
165165
default:
166-
alert( 'An unknown value' );
166+
alert( 'قيمة غير معروفة' );
167167
}
168168
```
169169
170-
1. For `0`, `1`, the first `alert` runs.
171-
2. For `2` the second `alert` runs.
172-
3. But for `3`, the result of the `prompt` is a string `"3"`, which is not strictly equal `===` to the number `3`. So we've got a dead code in `case 3`! The `default` variant will execute.
170+
1. إذا أدخلنا `0`, `1` يتم تنفيذ أول `alert`.
171+
2. إذا أدخلنا `2` يتم تنفيذ ثاني `alert`.
172+
3. ولكن إذا أدخلنا `3` تكون نتيجة `prompt` هي النص `"3"` الذي لا يطابق `===` الرقم `3`. لذلك لن يتم تنفيذ الأوامر في هذه `case 3`! وسيتم تنفيذ `default`.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
No difference.
1+
لا اختلاف.

0 commit comments

Comments
 (0)