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/05-types/article.md
+11-1Lines changed: 11 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -46,13 +46,23 @@ n = 12.345;
46
46
alert( "not a number" / 2 ); // NaN، چنین تقسیمی اشتباه است
47
47
```
48
48
49
+
<<<<<<<HEAD
49
50
هر عملی بر روی `NaN` نتیجه `NaN` خواهد داشت:
51
+
=======
52
+
`NaN` is sticky. Any further mathematical operation on `NaN` returns `NaN`:
53
+
>>>>>>> bae0ef44d0208506f6e9b7f3421ee640ab41af2b
50
54
51
55
```js run
52
-
alert( "not a number" / 2 + 5 ); // NaN
56
+
alert( NaN + 1 ); // NaN
57
+
alert( 3 * NaN ); // NaN
58
+
alert( "not a number" / 2 - 1 ); // NaN
53
59
```
54
60
61
+
<<<<<<<HEAD
55
62
در نتیجه اگر `NaN` در عملیات ریاضیاتیای وجود داشته باشد، بر روی تمام معادله تاثیر میگذارد (نتیجه معادله برابر `NaN` خواهد بود).
63
+
=======
64
+
So, if there's a `NaN` somewhere in a mathematical expression, it propagates to the whole result (there's only one exception to that:`NaN ** 0` is `1`).
65
+
>>>>>>> bae0ef44d0208506f6e9b7f3421ee640ab41af2b
56
66
57
67
```smart header="عملیات ریاضیاتی امن هستند"
58
68
عملیات ریاضی در جاوااسکریپت امن است. ما هر نوع عملی میتوانیم انجام دهیم مانند تقسیم بر صفر، رفتار کردن با رشتههای غیر عددی همانند اعداد و غیره.
Copy file name to clipboardExpand all lines: 1-js/02-first-steps/12-nullish-coalescing-operator/article.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -106,7 +106,11 @@ alert(height ?? 100); // 0
106
106
107
107
## اولویت
108
108
109
+
<<<<<<< HEAD
109
110
اولویت عملگر `??` تقریبا برابر با عملگر `||` است، اما کمتر. اولویت آن در [جدول MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence#Table) برابر با `5` است، در حالی که اولویت `||` برابر با `6` است.
111
+
=======
112
+
The precedence of the `??` operator is the same as `||`. They both equal `4` in the [MDN table](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence#Table).
113
+
>>>>>>> bae0ef44d0208506f6e9b7f3421ee640ab41af2b
110
114
111
115
این یعنی که درست مانند `||`، عملگر nullish coalescing `??` قبل از `=` و `?` ارزیابی میشود، اما بعد از بیشتر عملیاتها مانند `+`، `-` ارزیابی میشود.
Copy file name to clipboardExpand all lines: 1-js/02-first-steps/17-arrow-functions-basics/article.md
+8Lines changed: 8 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,7 +33,11 @@ let sum = function(a, b) {
33
33
alert(sum(1, 2)); // 3
34
34
```
35
35
36
+
<<<<<<< HEAD
36
37
همانطور که میبینید `(a, b) => a + b` بدین معنیست که این تابع دو آرگومان با نامهای `a` و `b` میپذیرد. و هنگام اجرا شدن، مقدار `a + b` را حساب میکند و نتیجه را برمیگرداند.
38
+
=======
39
+
As you can see, `(a, b) => a + b` means a function that accepts two arguments named `a` and `b`. Upon the execution, it evaluates the expression `a + b` and returns the result.
40
+
>>>>>>> bae0ef44d0208506f6e9b7f3421ee640ab41af2b
37
41
38
42
- اگر فقط یک آرگومان داشته باشیم میتوانیم پرانتزهای دور آرگومان را حذف کنیم و کد را از این هم کوتاهتر کنیم.
39
43
@@ -84,7 +88,11 @@ welcome();
84
88
letsum= (a, b) => { // کمانک یک تابع چندخظی را دربرمیگیرد
85
89
let result = a + b;
86
90
*!*
91
+
<<<<<<<HEAD
87
92
return result; // اگر از کمانک استفاده کنیم باید از return استفاده کنیم
93
+
=======
94
+
return result; // if we use curly braces, then we need an explicit "return"
ولی در بسیاری از موارد عملی، ما ترجیح میدهیم به جای خطا، `undefined` را دریافت کنیم (به معنای "بدون خیابان").
27
27
28
+
<<<<<<< HEAD
28
29
...و مثالی دیگر، در توسعه وب، ما میتوانیم یک شیء که با یک المان در صفحه مطابقت دارد را با استفاده از یک متد خاص، مانند `document.querySelector('.elem')` بگیریم و این متد هنگامی که چنین المانی وجود نداشته باشد `null` را برمیگرداند:
30
+
=======
31
+
...and another example. In Web development, we can get an object that corresponds to a web page element using a special method call, such as `document.querySelector('.elem')`, and it returns `null` when there's no such element.
32
+
>>>>>>> bae0ef44d0208506f6e9b7f3421ee640ab41af2b
29
33
30
34
```js run
31
35
// document.querySelector('.elem') خواهد شد اگر المنت وجود نداشته باشد null برابر با
Copy file name to clipboardExpand all lines: 1-js/05-data-types/10-destructuring-assignment/article.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,9 +5,13 @@
5
5
- شیءها به ما این امکان را میدهند تا چیزی بسازیم که المانهای داده را به واسطه کلید ذخیره کند.
6
6
- آرایهها به ما امکان جمعآوری المانهای داده را در لیستی مرتب میدهند.
7
7
8
+
<<<<<<< HEAD
8
9
اگرچه، زمانی که ما آنها را به تابع میدهیم، ممکن است که نیازی به کل یک شیء/آرایه نباشد. ممکن است تنها قطعههای تکی نیاز باشد.
9
10
10
11
*مقداردهیِ تجزیهکنندهی ساختار (Destructuring assignment)* یک سینتکس خاص است که به ما امکان میدهد تا آرایهها یا شیءها را درون چند متغیر «پخش کنیم» چون بعضی اوقات این موضوع کار را راحتتر میکند.
12
+
=======
13
+
Although, when we pass those to a function, it may need not be an object/array as a whole. It may need individual pieces.
14
+
>>>>>>> bae0ef44d0208506f6e9b7f3421ee640ab41af2b
11
15
12
16
تخریب ساختار همچنین با تابعهای پیچیده که تعداد زیادی پارامتر، مقدارهای پیشفرض و... دارند هم به خوبی کار میکند. به زودی آن را خواهیم دید.
3.`3.js` را بارگذاری میکنیم سپس اگر خطایی نداشت -- کار دیگری انجام میدهیم`(*)`
199
205
206
+
<<<<<<< HEAD
200
207
هرچقدر فراخوانی های ما تودرتو باشند کدهای مارا عمیقتر و غیرقابل فهم و مدیریت میکنند مخصوصا اگر به جای ... ها کدهای واقعی داشته باشیم که خود شامل حلقه ها و شرط ها و هر جمله دیگری هستند.
208
+
=======
209
+
In the code above:
210
+
1. We load `1.js`, then if there's no error...
211
+
2. We load `2.js`, then if there's no error...
212
+
3. We load `3.js`, then if there's no error -- do something else `(*)`.
213
+
214
+
As calls become more nested, the code becomes deeper and increasingly more difficult to manage, especially if we have real code instead of `...` that may include more loops, conditional statements and so on.
215
+
>>>>>>> bae0ef44d0208506f6e9b7f3421ee640ab41af2b
201
216
202
217
که معمولا به آن "جهنم فراخوانی" (callback-hell / pyramid of doom) میگویند.
203
218
@@ -262,7 +277,13 @@ function step3(error, script) {
262
277
```
263
278
همینجوری که مشاهده میکنید نتیجه تغییری نکرد ولی از تودرتو بودن فراخوانی ها با تعریف کردن توابع به صورت جداگانه برای هر مرحله از تودرتو بودن عمیق جلوگیری کردیم.
264
279
280
+
<<<<<<< HEAD
265
281
این روش کار میکند ولی کدش تکه تکه و جدا از هم است که خواندن آن را سخت میکند. همانطور که احتمالا دیدید لازم است در حین خواندن از جایی به جای دیگر بپرید. این طور اصلا راحت نیست مخصوصا اگر به کد آشنا نباشید و ندانید باید برای ادامه کد کجا را بخوانید.
282
+
=======
283
+
See? It does the same thing, and there's no deep nesting now because we made every action a separate top-level function.
284
+
285
+
It works, but the code looks like a torn apart spreadsheet. It's difficult to read, and you probably noticed that one needs to eye-jump between pieces while reading it. That's inconvenient, especially if the reader is not familiar with the code and doesn't know where to eye-jump.
286
+
>>>>>>> bae0ef44d0208506f6e9b7f3421ee640ab41af2b
266
287
267
288
همچنین توابعِ `step*` فقط یکبار استفاده میشوند و فقط برای جلوگیری از بوجود امدن جهنم فراخوانی و تودرتویی بیش از حد تعریف شده اند که باعث بی نظمی زیادی در کد میشوند.
Copy file name to clipboardExpand all lines: 1-js/11-async/03-promise-chaining/article.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -120,7 +120,7 @@ new Promise(function(resolve, reject) {
120
120
});
121
121
```
122
122
123
-
Here the first `.then` shows `1` and returns `new Promise(…)` in the line `(*)`. After one second it resolves, and the result (the argument of `resolve`, here it's `result * 2`) is passed on to handler of the second `.then`. That handler is in the line `(**)`, it shows `2` and does the same thing.
123
+
Here the first `.then` shows `1` and returns `new Promise(…)` in the line `(*)`. After one second it resolves, and the result (the argument of `resolve`, here it's `result * 2`) is passed on to the handler of the second `.then`. That handler is in the line `(**)`, it shows `2` and does the same thing.
124
124
125
125
So the output is the same as in the previous example: 1 -> 2 -> 4, but now with 1 second delay between `alert` calls.
0 commit comments