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
ما در اینجا یک ثابت با نام `birthday` داریم و ثابتی دیگر با نام `age` که با کمک کدهای دیگر از `birthday` محاسبه میشود (برای کوتاه شدن ارائه نشدهاست، و همچنین به دلیل اینکه جزییات اینجا اهمیت ندارند).
17
+
=======
18
+
Here we have a constant `birthday` for the date, and also the `age` constant.
19
+
20
+
The `age` is calculated from `birthday` using `someCode()`, which means a function call that we didn't explain yet (we will soon!), but the details don't matter here, the point is that `age` is calculated somehow based on the `birthday`.
21
+
>>>>>>> ff4ef57c8c2fd20f4a6aa9032ad37ddac93aa3c4
16
22
17
23
آیا نوشتن `birthday` با حروف بزرگ درست است؟ برای `age` چطور؟
18
24
19
25
```js
26
+
<<<<<<<HEAD
20
27
constBIRTHDAY='18.04.1982'; // با حروف بزرگ؟
21
28
22
29
constAGE=someCode(BIRTHDAY); // با حروف بزرگ؟
23
-
```
30
+
=======
31
+
constBIRTHDAY='18.04.1982'; // make birthday uppercase?
24
32
33
+
constAGE=someCode(BIRTHDAY); // make age uppercase?
این راه حل یک پیچیدگی زمانی [O(n<sup>2</sup>)](https://fa.wikipedia.org/wiki/نماد_O_بزرگ) دارد، به عبارتی دیگر، اگر ما اندازه آرایه را دو برابر کنیم، الگوریتم 4 برابر بیشتر زمان میبرد.
61
61
62
+
<<<<<<< HEAD
62
63
برای آرایههای بزرگ (1000، 10000 یا المانهای بیشتر) چنین الگوریتمی میتواند باعث سستی جدی شود.
64
+
=======
65
+
For big arrays (1000, 10000 or more items) such algorithms can lead to serious sluggishness.
الگوریتم دقیقا به 1 آرایه نیاز دارد، پس پیچیدگی زمان O(n) است.
93
97
98
+
<<<<<<< HEAD
94
99
شما میتوانید اطلاعات بیشتری درباره الگوریتم را اینجا پیدا کنید: [مسئله زیرآرایه بیشینه](http://en.wikipedia.org/wiki/Maximum_subarray_problem). اگر هنوز هم برای شما مشخص نیست که چرا کار میکند، لطفا الگوریتم را در مثال بالا دنبال کنید، ببینید چگونه کار میکند، این کار بهتر از حرفی است.
100
+
=======
101
+
You can find more detailed information about the algorithm here: [Maximum subarray problem](http://en.wikipedia.org/wiki/Maximum_subarray_problem). If it's still not obvious why that works, then please trace the algorithm on the examples above, see how it works, that's better than any words.
Copy file name to clipboardExpand all lines: 1-js/05-data-types/07-map-set/article.md
+54Lines changed: 54 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,13 +14,23 @@
14
14
15
15
متدها و ویژگیهای آن:
16
16
17
+
<<<<<<< HEAD
17
18
-`new Map()` -- map را میسازد.
18
19
-`map.set(key, value)` -- value را به واسطه key ذخیره میکند.
19
20
-`map.get(key)` -- مقدار را به واسطه key برمیگرداند، اگر `key` در map وجود نداشته باشد `undefined` برگردانده میشود.
20
21
-`map.has(key)` -- اگر `key` وجود داشته باشد `true` برگردانده میشود، در غیر این صورت `false`.
21
22
-`map.delete(key)` -- مقدار را به واسطه key حذف میکند.
22
23
-`map.clear()` -- همه چیز را از map حذف میکند.
23
24
-`map.size` -- تعداد المانهای کنونی را برمیگرداند.
25
+
=======
26
+
-`new Map()` -- creates the map.
27
+
-[`map.set(key, value)`](mdn:js/Map/set) -- stores the value by the key.
28
+
-[`map.get(key)`](mdn:js/Map/get) -- returns the value by the key, `undefined` if `key` doesn't exist in map.
29
+
-[`map.has(key)`](mdn:js/Map/has) -- returns `true` if the `key` exists, `false` otherwise.
30
+
-[`map.delete(key)`](mdn:js/Map/delete) -- removes the value by the key.
31
+
-[`map.clear()`](mdn:js/Map/clear) -- removes everything from the map.
32
+
-[`map.size`](mdn:js/Map/size) -- returns the current element count.
33
+
>>>>>>> ff4ef57c8c2fd20f4a6aa9032ad37ddac93aa3c4
24
34
25
35
برای مثال:
26
36
@@ -105,9 +115,15 @@ map.set('1', 'str1')
105
115
106
116
برای حلقه زدن در `map` 3 متد وجود دارد:
107
117
118
+
<<<<<<< HEAD
108
119
- `map.keys()` -- یک حلقهپذیر برای کلیدها برمیگرداند،
109
120
- `map.values()` -- یک حلقهپذیر برای مقدارها برمیگرداند،
110
121
- `map.entries()` -- یک حلقهپذیر برای برای اطلاعات به شکل `[key, value]` برمیگرداند که به صورت پیشفرض در `for..of` استفاده میشود.
122
+
=======
123
+
- [`map.keys()`](mdn:js/Map/keys) -- returns an iterable for keys,
124
+
- [`map.values()`](mdn:js/Map/values) -- returns an iterable for values,
125
+
- [`map.entries()`](mdn:js/Map/entries) -- returns an iterable for entries `[key, value]`, it's used by default in `for..of`.
126
+
>>>>>>> ff4ef57c8c2fd20f4a6aa9032ad37ddac93aa3c4
111
127
112
128
برای مثال:
113
129
@@ -237,12 +253,21 @@ let obj = Object.fromEntries(map); // را حذف کردیم .entries()
237
253
238
254
متدهای اصلی آن:
239
255
256
+
<<<<<<< HEAD
240
257
- `new Set(iterable)` -- set را ایجاد میکند و اگر یک شیء حلقهپذیر داده شود (معمولا یک آرایه)، مقدارها را از آن درون set کپی میکند.
241
258
- `set.add(value)` -- یک مقدار اضافه میکند و خود set را برمیگرداند.
242
259
- `set.delete(value)` -- مقدار را حذف میکند و اگر `value` هنگام فراخوانی وجود داشته باشد `true` را برمیگرداند، در غیر این صورت `false`.
243
260
- `set.has(value)` -- اگر مقدار در set وجود داشته باشد `true` را برمیگرداند، در غیر این صورت `false`.
244
261
- `set.clear()` -- همه چیز را از set حذف میکند.
245
262
- `set.size` -- برابر با تعداد المانها است.
263
+
=======
264
+
- `new Set(iterable)` -- creates the set, and if an `iterable` object is provided (usually an array), copies values from it into the set.
265
+
- [`set.add(value)`](mdn:js/Set/add) -- adds a value, returns the set itself.
266
+
- [`set.delete(value)`](mdn:js/Set/delete) -- removes the value, returns `true` if `value` existed at the moment of the call, otherwise `false`.
267
+
- [`set.has(value)`](mdn:js/Set/has) -- returns `true` if the value exists in the set, otherwise `false`.
268
+
- [`set.clear()`](mdn:js/Set/clear) -- removes everything from the set.
269
+
- [`set.size`](mdn:js/Set/size) -- is the elements count.
270
+
>>>>>>> ff4ef57c8c2fd20f4a6aa9032ad37ddac93aa3c4
246
271
247
272
ویژگی اصلی این اصت که فراخوانیهای پیدرپی `set.add(value)` با مقداری یکسان، کاری انجام نمیدهد. به همین دلیل است که هر مقدار تنها یک بار در `Set` واقع میشوند.
یک چیز جالب را در نظر داشته باشید. تابعی که به `forEach` داده شده 3 آرگومان دارد: یک `value`، سپس *مقدار یکسان* `valueAgain` و سپس شیء مورد نظر. در واقع، مقداری یکسان دو بار در آرگومان ظاهر میشود.
293
318
319
+
<<<<<<< HEAD
294
320
این به دلیل سازگاری با `Map` است که تابع داده شده به `forEach` دارای 3 آرگومان است. قطعا کمی عجیب به نظر میرسد. اما میتواند به جایگزینی `Map` با `Set` و برعکس در بعضی موارد کمک کند.
321
+
=======
322
+
That's for compatibility with `Map` where the callback passed `forEach` has three arguments. Looks a bit strange, for sure. But this may help to replace `Map` with `Set` in certain cases with ease, and vice versa.
323
+
>>>>>>> ff4ef57c8c2fd20f4a6aa9032ad37ddac93aa3c4
295
324
296
325
همچنین متدهای مشابهی که `Map` هم برای حلقهزنندهها دارد، پشتیبانی میشوند:
297
326
327
+
<<<<<<< HEAD
298
328
- `set.keys()` -- یک شیء حلقهپذیر برای مقدارها را برمیگرداند،
299
329
- `set.values()` -- با `set.keys()` یکسان است، برای سازگاری با `Map`
300
330
- `set.entries()` -- یک شیء حلقهپذیر را برای اطلاعات به شکل `[value, value]` برمیگرداند، برای سازگاری با `Map` وجود دارد.
331
+
=======
332
+
- [`set.keys()`](mdn:js/Set/keys) -- returns an iterable object for values,
333
+
- [`set.values()`](mdn:js/Set/values) -- same as `set.keys()`, for compatibility with `Map`,
334
+
- [`set.entries()`](mdn:js/Set/entries) -- returns an iterable object for entries `[value, value]`, exists for compatibility with `Map`.
335
+
>>>>>>> ff4ef57c8c2fd20f4a6aa9032ad37ddac93aa3c4
301
336
302
337
## خلاصه
303
338
304
339
`Map` -- یک مجموعه از مقدارهای کلیددار است.
305
340
306
341
متدها و ویژگیهای آن:
307
342
343
+
<<<<<<< HEAD
308
344
- `new Map([iterable])` -- map را میسازد، برای مقداردهی اولیه از `iterable`(حلقهپذیر) اختیاری (مانند آرایه) از جفتهای `[key,value]` میتوان استفاده کرد.
309
345
- `map.set(key, value)` -- مقدار را به واسطه کلید ذخیره میکند، خود map را برمیگرداند.
310
346
- `map.get(key)` -- مقدار را به واسطه کلید برمیگرداند، اگر `key` در map وجود نداشته باشد `undefined` برمیگرداند.
311
347
- `map.has(key)` -- اگر `key` وجود داشته باشد `true` برمیگرداند، در غیر این صورت `false`.
312
348
- `map.delete(key)` -- مقدار را به واسطه کلید حذف میکند، اگر `key` در لحظه فراخوانی وجود داشته باشد `true` برمیگرداند، در غیر این صورت `false`.
313
349
- `map.clear()` -- همه چیز را از map حذف میکند.
314
350
- `map.size` -- تعداد المانها را برمیگرداند.
351
+
=======
352
+
- `new Map([iterable])` -- creates the map, with optional `iterable` (e.g. array) of `[key,value]` pairs for initialization.
353
+
- [`map.set(key, value)`](mdn:js/Map/set) -- stores the value by the key, returns the map itself.
354
+
- [`map.get(key)`](mdn:js/Map/get)` -- returns the value by the key, `undefined` if `key` doesn't exist in map.
355
+
- [`map.has(key)`](mdn:js/Map/has) -- returns `true` if the `key` exists, `false` otherwise.
356
+
- [`map.delete(key)`](mdn:js/Map/delete) -- removes the value by the key, returns `true` if `key` existed at the moment of the call, otherwise `false`.
357
+
- [`map.clear()`](mdn:js/Map/clear) -- removes everything from the map.
358
+
- [`map.size`](mdn:js/Map/size) -- returns the current element count.
- `new Set([iterable])` -- set را ایجاد میکند، برای مقداردهی اولیه میتوان از `iterable`(حلقهپذیر مانند آرایه) شامل مقدارها استفاده کرد.
326
372
- `set.add(value)` -- یک مقدار را اضافه میکند (اگر `value` وجود داشته باشد کاری نمیکند)، خود set را برمیگرداند.
327
373
- `set.delete(value)` -- مقدار را حذف میکند، اگر `value` هنگام فراخوانی وجود داشته باشد `true` را برمیگرداند، در غیر این صورت `false`.
328
374
- `set.has(value)` -- اگر مقدار در set وجود داشته باشد `true` را برمیگرداند، در غیر این صورت `false`.
329
375
- `set.clear()` -- همه چیز را از set حذف میکند.
330
376
- `set.size` -- برابر با تعداد المانها است.
377
+
=======
378
+
- `new Set([iterable])` -- creates the set, with optional `iterable` (e.g. array) of values for initialization.
379
+
- [`set.add(value)`](mdn:js/Set/add) -- adds a value (does nothing if `value` exists), returns the set itself.
380
+
- [`set.delete(value)`](mdn:js/Set/delete) -- removes the value, returns `true` if `value` existed at the moment of the call, otherwise `false`.
381
+
- [`set.has(value)`](mdn:js/Set/has) -- returns `true` if the value exists in the set, otherwise `false`.
382
+
- [`set.clear()`](mdn:js/Set/clear) -- removes everything from the set.
383
+
- [`set.size`](mdn:js/Set/size) -- is the elements count.
384
+
>>>>>>> ff4ef57c8c2fd20f4a6aa9032ad37ddac93aa3c4
331
385
332
386
حلقهزدن در `Map` و `Set` همیشه با ترتیب اضافهکردن انجام میشود، پس ما نمیتوانیم بگوییم این مجموعهها نامرتب هستند اما نمیتوانیم المانها را دوباره مرتب کنیم یا به صورت مستقیم یک المان را با استفاده از عدد آن دریافت کنیم.
Copy file name to clipboardExpand all lines: 1-js/99-js-misc/04-reference-type/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
@@ -87,7 +87,7 @@ The result of a property access `user.hi` is not a function, but a value of Refe
87
87
(user, "hi", true)
88
88
```
89
89
90
-
When parentheses `()` are called on the Reference Type, they receive the full information about the object and its method, and can set the right `this` (`=user` in this case).
90
+
When parentheses `()` are called on the Reference Type, they receive the full information about the object and its method, and can set the right `this` (`user` in this case).
91
91
92
92
Reference type is a special "intermediary" internal type, with the purpose to pass information from dot `.` to calling parentheses `()`.
0 commit comments