Skip to content

Commit a3e56b2

Browse files
committed
merging all conflicts
2 parents 115385e + 741d90c commit a3e56b2

3 files changed

Lines changed: 73 additions & 0 deletions

File tree

1-js/04-object-basics/07-optional-chaining/article.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,15 @@ alert( user?.address.street ); // undefined
108108
```warn header="از زنجیره‌ی اختیاری بیش از حد استفاده نکنید"
109109
ما باید از `.?` فقط زمانی استفاده کنیم که عدم وجود چیزی اشکالی ندارد.
110110

111+
<<<<<<< HEAD
111112
برای مثال، اگر طبق منطق کد ما باید شیء `user` وجود داشته باشد ولی `address` اختیاری باشد، پس ما باید اینگونه بنویسیم `user.address?.street` نه `user?.address?.street`.
112113

113114
بنابراین، اگر تصادفاً به دلیل اشتباهی ‍`user` برابر با `undefined` باشد، شاهد یک خطای برنامه‌نویسی در مورد آن خواهیم بود و آن را برطرف خواهیم کرد. در غیر این صورت، خطاهای کد را می توان در مواردی که مناسب نیست ساکت کرد، و این کار اشکال‌زدایی را سخت‌تر می‌کند.
115+
=======
116+
For example, if according to our code logic `user` object must exist, but `address` is optional, then we should write `user.address?.street`, but not `user?.address?.street`.
117+
118+
Then, if `user` happens to be undefined, we'll see a programming error about it and fix it. Otherwise, if we overuse `?.`, coding errors can be silenced where not appropriate, and become more difficult to debug.
119+
>>>>>>> 741d90ce8a730d66e987bff5e9794d6e41cb2f05
114120
```
115121
116122
````warn header="متغیر قبل از `.?` باید تعریف شده باشد"
@@ -127,15 +133,23 @@ user?.address;
127133
128134
همانطور که قبلا گفته شد عبارت `.?` اگر عبارت سمت چپ آن وجود نداشته باشد، فوراً ارزیابی را متوقف می‌کند (اتصال را کوتاه می‌کند).
129135
136+
<<<<<<< HEAD
130137
بنابراین، اگر صدازدن تابعی یا عوارض جانبی دیگری وجود داشته باشند، اتفاق نمی‌افتند.
138+
=======
139+
So, if there are any further function calls or operations to the right of `?.`, they won't be made.
140+
>>>>>>> 741d90ce8a730d66e987bff5e9794d6e41cb2f05
131141

132142
برای نمونه:
133143

134144
```js run
135145
let user = null;
136146
let x = 0;
137147
148+
<<<<<<< HEAD
138149
user?.sayHi(x++); // اجرا نمی‌شود x++ وجود ندارد، پس "sayHi"
150+
=======
151+
user?.sayHi(x++); // no "user", so the execution doesn't reach sayHi call and x++
152+
>>>>>>> 741d90ce8a730d66e987bff5e9794d6e41cb2f05
139153
140154
alert(x); // 0 :مقدار افزایش نیافته پس
141155
```

1-js/05-data-types/02-number/article.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@ alert( 7.3e9 ); // 7.3 billions (same as 7300000000 or 7_300_000_000)
4747
let mсs = 0.000001;
4848
```
4949

50+
<<<<<<< HEAD
5051
دقیقا مثل قبل، استفاده از `"e"` میتواند کمک کند. اگر ما بخواهیم که از نوشتن صفرها خودداری کنیم، میتوانیم بنویسیم که:
52+
=======
53+
Just like before, using `"e"` can help. If we'd like to avoid writing the zeroes explicitly, we could write the same as:
54+
>>>>>>> 741d90ce8a730d66e987bff5e9794d6e41cb2f05
5155
5256
```js
5357
let mcs = 1e-6; // شش صفر در سمت چپ ۱
@@ -156,7 +160,11 @@ alert( num.toString(2) ); // 11111111
156160

157161
۱. ضرب و تقسیم
158162

163+
<<<<<<< HEAD
159164
برای مثال، برای رند کردن عدد تا دومین رقم اعشاری، میتوانیم عدد را در`۱۰۰` (یا یک توان بزرگ‌تر ۱۰) ضرب کنیم، تابع رند کردن را صدا بزنیم و سپس دوباره تقسیم کنیم.
165+
=======
166+
For example, to round the number to the 2nd digit after the decimal, we can multiply the number by `100`, call the rounding function and then divide it back.
167+
>>>>>>> 741d90ce8a730d66e987bff5e9794d6e41cb2f05
160168
```js run
161169
let num = 1.23456;
162170

@@ -184,21 +192,33 @@ alert( num.toString(2) ); // 11111111
184192
alert( num.toFixed(5) ); // "12.34000", صفر اضافه شده تا دقیقا ۵ رقم شود
185193
```
186194

195+
<<<<<<< HEAD
187196
ما میتوانیم آن را با کمک جمع واحد یا با فراخوانی `Number()` در `+num.toFixed(5)` به عدد تبدیل کنیم
197+
=======
198+
We can convert it to a number using the unary plus or a `Number()` call, e.g write `+num.toFixed(5)`.
199+
>>>>>>> 741d90ce8a730d66e987bff5e9794d6e41cb2f05
188200

189201
## محاسبات تقریبی
190202

191203
در درون سیستم، یک عدد به شکل ۶۴-بیتی است [IEEE-754](http://en.wikipedia.org/wiki/IEEE_754-1985)، بنابراین دقیقا ۶۴ بیت برای ذخیره‌ی یک عدد داریم: ۵۲ تا از آنها برای ذخیره کردن ارقام هستند، ۱۱ تا از آنها برای ذخیره کردن جایگاه نقطه‌ی مشخص کننده‌ی اعشار (که برای اعداد صحیح صفر است)، و یک بیت برای علامت آن.
192204

205+
<<<<<<< HEAD
193206
اگر عددی بیش از حد بزرگ باشد، حافظه‌ی ۶۴ بیتی سرریز میکند و مقدار بینهایت را برمیگرداند:
207+
=======
208+
If a number is really huge, it may overflow the 64-bit storage and become a special numeric value `Infinity`:
209+
>>>>>>> 741d90ce8a730d66e987bff5e9794d6e41cb2f05
194210

195211
```js run
196212
alert( 1e500 ); // Infinity
197213
```
198214

199215
اتفاقی که زیاد مشخص نیست و کمتر اتفاق می‌افتد، از دست دادن دقت است.
200216

217+
<<<<<<< HEAD
201218
این آزمون (اشتباه!) را در نظر بگیرید:
219+
=======
220+
Consider this (falsy!) equality test:
221+
>>>>>>> 741d90ce8a730d66e987bff5e9794d6e41cb2f05
202222

203223
```js run
204224
alert( 0.1 + 0.2 == 0.3 ); // *!*false*/!*
@@ -212,13 +232,21 @@ alert( 0.1 + 0.2 == 0.3 ); // *!*false*/!*
212232
alert( 0.1 + 0.2 ); // 0.30000000000000004
213233
```
214234

235+
<<<<<<< HEAD
215236
اوه! اتفاقات بدتری تا یک مقایسه‌ی ساده میتواند بیفتد. مثلا فرض کنید شما در فروشگاهی اینترنتی مقدار `$0.10` و `$0.20` را به حساب خود واریز میکنید. مجموع موجودی شما `$0.30000000000000004` میشود. این شکه کننده‌ست!
237+
=======
238+
Ouch! Imagine you're making an e-shopping site and the visitor puts `$0.10` and `$0.20` goods into their cart. The order total will be `$0.30000000000000004`. That would surprise anyone.
239+
>>>>>>> 741d90ce8a730d66e987bff5e9794d6e41cb2f05
216240

217241
اما چرا این اتفاق می‌افتد؟
218242

219243
یک عدد در حافظه به شکل دودویی آن ذخیره میشود، مجموعه‌ای از صفرها و یک‌ها. اما کسرهایی مثل `0.1`، `0.2` که در سیستم اعداد اعشاری ساده به نظر میرسند در اصل کسرهای بی‌پایانی در شکل دودویی خود هستند.
220244

245+
<<<<<<< HEAD
221246
به زبانی دیگر، `0.1` چیست؟ مقدار یک که بر ده تقسیم شده، `1/10` یعنی یک دهم. در سیستم اعداد اعشاری چنین اعدادی به سادگی قابل نمایشند. با یک سوم `1/3` مقایسه کنید. به کسری بی‌پایان تبدیل میشود. `0.33333(3)`
247+
=======
248+
What is `0.1`? It is one divided by ten `1/10`, one-tenth. In decimal numeral system such numbers are easily representable. Compare it to one-third: `1/3`. It becomes an endless fraction `0.33333(3)`.
249+
>>>>>>> 741d90ce8a730d66e987bff5e9794d6e41cb2f05
222250

223251
بنابراین، تقسیم های از توان ده، قطعا در سیستم اعشاری کار میکند اما تقسیم‌های بر ۳ اینطور نیست. به علت مشابه، در سیستم اعداد دودویی، تقسیم توان‌های ۲ هم قطعا کار میکند اما ۱/۱۰، کسر دودویی بی‌پایانی میشود.
224252

1-js/09-classes/03-static-properties-methods/article.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11

22
# ویژگی و متدهای ایستا
33

4+
<<<<<<< HEAD
45
ما می‌توانیم یک متد را در خود تابع کلاس هم قرار دهیم، نه درون `"prototype"` آن. چنین متدهایی *ایستا (static)* نامیده می‌شوند.
56

67
در یک کلاس، آن‌ها با کلمه کلیدی `static` استفاده می‌شوند، مثل این:
8+
=======
9+
We can also assign a method to the class as a whole. Such methods are called *static*.
10+
11+
In a class declaration, they are prepended by `static` keyword, like this:
12+
>>>>>>> 741d90ce8a730d66e987bff5e9794d6e41cb2f05
713
814
```js run
915
class User {
@@ -31,9 +37,17 @@ User.staticMethod(); // true
3137

3238
مقدار `this` درون فراخوانی `User.staticMethod()` برابر با کلاس سازنده یعنی خود `User` است (قانون «شیء قبل از نقطه»).
3339

40+
<<<<<<< HEAD
3441
معمولا، متدهای ایستا برای پیاده‌سازی تابع‌هایی که به کلاس تعلق دارند و نه به هر شیء خاصی از آن استفاده می‌شوند.
3542

3643
برای مثال، ما شیءهای کلاس `Article` (به معنی مقاله) را داریم و به تابعی برای مقایسه آن‌ها نیاز داریم. یک راه‌حل طبیعی اضافه کردن متد `Article.compare` است، مثلا اینگونه:
44+
=======
45+
Usually, static methods are used to implement functions that belong to the class as a whole, but not to any particular object of it.
46+
47+
For instance, we have `Article` objects and need a function to compare them.
48+
49+
A natural solution would be to add `Article.compare` static method:
50+
>>>>>>> 741d90ce8a730d66e987bff5e9794d6e41cb2f05
3751
3852
```js run
3953
class Article {
@@ -63,17 +77,29 @@ articles.sort(Article.compare);
6377
alert( articles[0].title ); // CSS
6478
```
6579

80+
<<<<<<< HEAD
6681
اینجا `Article.compare` در «بالای» مقاله‌ها (articles) قرار دارد، به عنوان روشی برای مقایسه آن‌ها. این متدی برای یک مقاله(article) نیست، بلکه برای کل کلاس است.
6782

6883
مثال دیگر متدی به نام "factory" (به معنی تولیدکننده) است. فرض کنید، ما به چند راه برای ایجاد یک مقاله نیاز داریم:
84+
=======
85+
Here `Article.compare` method stands "above" articles, as a means to compare them. It's not a method of an article, but rather of the whole class.
86+
87+
Another example would be a so-called "factory" method.
88+
89+
Let's say, we need multiple ways to create an article:
90+
>>>>>>> 741d90ce8a730d66e987bff5e9794d6e41cb2f05
6991
7092
1. ساختن از طریق پارامترها (`title`، `date` و غیره).
7193
2. ساختن یک مقاله خالی با تاریخ امروز.
7294
3. ...یا به روشی دیگر.
7395

7496
اولین راه می‌تواند با استفاده از تابع سازنده پیاده‌سازی شود. و برای راه دوم می‌توانیم یک متد ایستا برای کلاس بسازیم.
7597

98+
<<<<<<< HEAD
7699
مانند `Article.createTodays()` در اینجا:
100+
=======
101+
Such as `Article.createTodays()` here:
102+
>>>>>>> 741d90ce8a730d66e987bff5e9794d6e41cb2f05
77103
78104
```js run
79105
class Article {
@@ -100,8 +126,13 @@ alert( article.title ); // خلاصه‌ی امروز
100126
متدهای ایستا همچنین در کلاس‌های مربوط به پایگاه داده (database) برای جست‌وجو/ذخیره/حذف ورودی‌ها از پایگاه داده هم استفاده می‌شوند، مثلا اینگونه:
101127

102128
```js
129+
<<<<<<< HEAD
103130
// کلاسی خاص برای مدیریت مقاله‌ها است Article با فرض اینکه
104131
// :متد ایستا برای حذف مقاله‌ها
132+
=======
133+
// assuming Article is a special class for managing articles
134+
// static method to remove the article by id:
135+
>>>>>>> 741d90ce8a730d66e987bff5e9794d6e41cb2f05
105136
Article.remove({id: 12345});
106137
```
107138

0 commit comments

Comments
 (0)