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
+4-22Lines changed: 4 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -213,7 +213,6 @@ alert(x); // "undefined"
213
213
214
214
این عملگر نوع عبارت را نشان میدهد. معمولا زمانی که میخواهیم سریع نوع یک مقدار را بررسی کنیم یا زمانیکه میخواهیم پردازشی بر اساس نوع یک مقدار انجام دهیم، کاربرد دارد.
215
215
216
-
<<<<<<< HEAD
217
216
این عملگر به دو شکل قابل استفاده است:
218
217
219
218
1. به عنوان عملگر : `typeof x`.
@@ -222,9 +221,6 @@ alert(x); // "undefined"
222
221
به عبارتی دیگر، این عملگر هم با پرانتز کار میکند هم بدون آن. نتیجه هر دو یکسان است.
223
222
224
223
با صدا زدن `typeof x` رشته کاراکتری حاوی نوع آن مقدار نمایش داد میشود:
225
-
=======
226
-
A call to `typeof x` returns a string with the type name:
1. `Math` یک شیء built-in (از پیش نوشته شده در هسته زبان) است که عملیات متنوع ریاضیاتی را در اختیار ما قرار میدهد. ما آن را در فصل <info:number> یاد میگیریم. در اینجا صرفا یک مثال از آن را نمایش دادیم.
259
-
2. خروجی `typeofnull` همانطور که میبینید `"object"` است. این یک خطا در نوع کار `typeof` میباشد که به منظور سازگاری باقی مانده است. مطمئنا `null` یک object نیست. خودِ null یکی از انواع داده در جاوااسکریپت است.
260
-
3. خروجی `typeof alert``"function"` است چراکه `alert` خودش هم یک تابع است. ما در بخشهای بعدی با تابعها بیشتر آشنا خواهیم شد و خواهیم آموخت که نوعی تحت عنوان function در جاوااسکریپت نداریم. تابعها در اصل از نوعِ object هستند. اما عملگر `typeof` به آنها به طرز دیگری برخورد میکند و `function` را برمیگرداند. این هم از روزهای اول جاوااسکریپت وجود داشته است. به طور فنی، این رفتار درست نیست، اما در عمل میتواند مفید باشد.
261
-
262
-
## خلاصه
263
-
=======
264
-
1. `Math` is a built-in object that provides mathematical operations. We will learn it in the chapter <info:number>. Here, it serves just as an example of an object.
265
-
2. The result of `typeof null` is `"object"`. That's an officially recognized error in `typeof`, coming from very early days of JavaScript and kept for compatibility. Definitely, `null` is not an object. It is a special value with a separate type of its own. The behavior of `typeof` is wrong here.
266
-
3. The result of `typeof alert` is `"function"`, because `alert` is a function. We'll study functions in the next chapters where we'll also see that there's no special "function" type in JavaScript. Functions belong to the object type. But `typeof` treats them differently, returning `"function"`. That also comes from the early days of JavaScript. Technically, such behavior isn't correct, but can be convenient in practice.
254
+
2. خروجی `typeofnull` برابر با `"object"` است. این یک خطا در طرز کار `typeof` میباشد که از روزهای اول در جاوااسکریپت وجود داشته و به منظور سازگاری باقی مانده است. مطمئنا `null` یک object نیست. خودِ null یکی از انواع داده در جاوااسکریپت است.
255
+
3. خروجی `typeof alert` برابر با `"function"` است چراکه `alert` خودش هم یک تابع است. ما در بخشهای بعدی با تابعها بیشتر آشنا خواهیم شد و خواهیم آموخت که نوعی تحت عنوان function در جاوااسکریپت نداریم. تابعها در اصل از نوعِ object هستند. اما عملگر `typeof` با آنها به طرز دیگری برخورد میکند و `function` را برمیگرداند. این هم از روزهای اول جاوااسکریپت وجود داشته است. به طور فنی، این رفتار درست نیست، اما در عمل میتواند مفید باشد.
267
256
268
257
```smart header="The `typeof(x)` syntax"
269
258
You may also come across another syntax: `typeof(x)`. It's the same as `typeof x`.
@@ -275,8 +264,7 @@ Usually, such parentheses contain a mathematical expression, such as `(2 + 2)`,
275
264
Some people prefer `typeof(x)`, although the `typeof x` syntax is much more common.
276
265
```
277
266
278
-
## Summary
279
-
>>>>>>> 8d04d0d2db97276dbb2b451c30a7bd3e05d65831
267
+
## خلاصه
280
268
281
269
در جاوااسکریپت 8 نوع داده پایهای وجود دارد.
282
270
@@ -291,14 +279,8 @@ Some people prefer `typeof(x)`, although the `typeof x` syntax is much more comm
291
279
292
280
عملگر `typeof` به شما اجازه میدهد نوع مقدار ذخیره شده در یک متغیر را تشخصی دهید.
293
281
294
-
<<<<<<< HEAD
295
-
- به دو طریق : `typeof x` و یا `typeof(x)`.
282
+
- معمولا به صورت `typeof x` استفاده میشود، اما `typeof(x)` هم قابل قبول است.
296
283
- یک رشته شامل اسم نوع را برمیگرداند، مثل `"string"`.
297
284
- برای `null` مقدار `"object"` را نمایش میدهد -- این یک خطا در خودِ زبان است، در واقع null یک object نیست.
298
-
=======
299
-
- Usually used as `typeof x`, but `typeof(x)` is also possible.
300
-
- Returns a string with the name of the type, like `"string"`.
301
-
- For `null` returns `"object"` -- this is an error in the language, it's not actually an object.
302
-
>>>>>>> 8d04d0d2db97276dbb2b451c30a7bd3e05d65831
303
285
304
286
در فصلهای بعدی، ما روی نوعهای "اولیه" تمرکز میکنیم و هنگامی که با آنها بیشتر آشنا شدیم، به سراغ شیءها میرویم.
Copy file name to clipboardExpand all lines: 1-js/02-first-steps/16-function-expressions/article.md
+6-30Lines changed: 6 additions & 30 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,25 +12,16 @@ function sayHi() {
12
12
13
13
یک سینتکس دیگر هم برای ساخت تابع وجود دارد که *Function Expression* نامیده میشود.
14
14
15
-
<<<<<<< HEAD
16
-
اینطور به نظر میرسد:
17
-
=======
18
-
It allows to create a new function in the middle of any expression.
15
+
این سینتکس به ما این امکان را میدهد که بین هر عبارتی یک تابع جدید بسازیم.
19
16
20
-
For example:
21
-
>>>>>>> 8d04d0d2db97276dbb2b451c30a7bd3e05d65831
17
+
برای مثال:
22
18
23
19
```js
24
20
letsayHi=function() {
25
21
alert( "سلام" );
26
22
};
27
23
```
28
24
29
-
<<<<<<< HEAD
30
-
اینجا، تابع ساخته شده و مثل هر مقدار دیگری، صراحتا به متغیر تخصیص داده شده است. فرقی ندارد که تابع چگونه تعریف شده، تابع فقط یک مقدار است که داخل متغیر `sayHi` ذخیره شده است.
31
-
32
-
معنی این مثالهای کد یکسان است: "یک تابع بساز و آن را داخل متغیر `sayHi` بگذار".
33
-
=======
34
25
Here we can see a variable `sayHi` getting a value, the new function, created as `function() { alert("Hello"); }`.
35
26
36
27
As the function creation happens in the context of the assignment expression (to the right side of `=`), this is a *Function Expression*.
@@ -44,7 +35,6 @@ In more advanced situations, that we'll come across later, a function may be cre
44
35
## Function is a value
45
36
46
37
Let's reiterate: no matter how the function is created, a function is a value. Both examples above store a function is `sayHi` variable.
47
-
>>>>>>> 8d04d0d2db97276dbb2b451c30a7bd3e05d65831
48
38
49
39
ما حتی میتوانیم آن مقدار را با استفاده از `alert` چاپ کنیم:
50
40
@@ -85,19 +75,11 @@ sayHi(); // سلام // هنوزم کار میکند (چرا نکند)
85
75
2. خط `(2)` آن را داخل متغیر `func` کپی میکند. لطفا دوباره در نظر داشته باشید: هیچ پرانتزی بعد از `sayHi` وجود ندارد. اگر وجود داشت، سپس `func = sayHi()`*نتیجه صدا زدن*`sayHi()` را در `func` مینوشت، نه خود *تابع*`sayHi`.
86
76
3. حالا تابع میتواند با `sayHi()` و `func()` صدا زده شود.
87
77
88
-
<<<<<<< HEAD
89
-
همچنین توجه داشته باشید که ما میتوانستیم از یک Function Expression برای تعریف `sayHi` در خط اول، استفاده کنیم:
78
+
همچنین میتوانستیم از یک Function Expression برای تعریف `sayHi` در خط اول، استفاده کنیم:
90
79
91
80
```js
92
-
letsayHi=function() {
81
+
letsayHi=function() {// (1) ایجاد
93
82
alert( "سلام" );
94
-
=======
95
-
We could also have used a Function Expression to declare `sayHi`, in the first line:
96
-
97
-
```js
98
-
let sayHi = function() { // (1) create
99
-
alert( "Hello" );
100
-
>>>>>>> 8d04d0d2db97276dbb2b451c30a7bd3e05d65831
101
83
};
102
84
103
85
let func = sayHi;
@@ -120,15 +102,9 @@ let sayHi = function() {
120
102
}*!*;*/!*
121
103
```
122
104
123
-
<<<<<<<HEAD
124
-
جواب ساده است:
125
-
- هیچ نیازی به `;` در انتهای بلوکهای کد و ساختارهای سینتکس که از آنها مثل `if { ... }`، `for { }`، `function f { }` و... استفاده میشود نیست.
126
-
- یک Function Expression به عنوان یک مقدار، در داخل دستور استفاده میشود:`let sayHi = ...;`.این یک بلوک کد نیست، بلکه یک تخصیص دادن است. نقطه ویرگول `;` در انتهای دستورها پیشنهاد میشود، بدون توجه به اینکه مقدار چه چیزی باشد. پس نقطه ویرگول در اینجا به خود Function Expression مربوط نیست، فقط دستور را به پایان میرساند.
127
-
=======
128
-
The answer is simple: a Function Expression is created here as `function(…) {…}` inside the assignment statement:`let sayHi = …;`. The semicolon `;` is recommended at the end of the statement, it's not a part of the function syntax.
105
+
جواب ساده است: یک Function Expression به صورت `function(…) {…}`، در داخل دستور مقداردهی استفاده میشود: `let sayHi = ...;`. نقطه ویرگول `;` در انتهای دستور پیشنهاد میشود، این علامت جزء سینتکس تابع نیست.
129
106
130
-
The semicolon would be there for a simpler assignment, such as `let sayHi = 5;`, and it's also there for a function assignment.
131
-
>>>>>>> 8d04d0d2db97276dbb2b451c30a7bd3e05d65831
107
+
نقطه ویرگول برای مقداردهی سادهتر وجود دارد مثل `let sayHi = 5;` و همچنین برای مقداردهی تابع نیز وجود دارد.
Copy file name to clipboardExpand all lines: 1-js/02-first-steps/17-arrow-functions-basics/article.md
+1-5Lines changed: 1 addition & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,11 +8,7 @@
8
8
letfunc= (arg1, arg2, ..., argN) => expression;
9
9
```
10
10
11
-
<<<<<<< HEAD
12
-
...این کد یک تابع `func` میسازد که دو آرگومان `arg1..argN` میپذیرد و با استفاده از این دو آرگومان `expression` سمت راست را محاسبه میکند و نتیجه را برمیگرداند.
13
-
=======
14
-
This creates a function `func` that accepts arguments `arg1..argN`, then evaluates the `expression` on the right side with their use and returns its result.
15
-
>>>>>>> 8d04d0d2db97276dbb2b451c30a7bd3e05d65831
11
+
...این کد یک تابع `func` میسازد که آرگومانهای `arg1..argN` را میپذیرد و با استفاده از این آرگومانها `expression` سمت راست را ارزیابی میکند و نتیجه آن را برمیگرداند.
16
12
17
13
به بیانی دیگر، این کد نسخهی کوتاهشده کد زیر است:
Copy file name to clipboardExpand all lines: 1-js/04-object-basics/08-symbol/article.md
+1-5Lines changed: 1 addition & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -161,11 +161,7 @@ for (let key in user) alert(key); // name, age (بدون سمبل)
161
161
alert( "به طور مستقیم: "+ user[id] );
162
162
```
163
163
164
-
<<<<<<< HEAD
165
-
همچنین `Object.keys(user)` هم آنها را نادیده میگیرد. این یک بخش از اصل کلی «مخفیسازی ویژگیهای سمبلی» است. اگر یک اسکریپت یا کتابخانه دیگر در شیء ما حلقه بزند، به تصادفی به ویژگی سمبلی ما دسترسی نخواهد داشت.
166
-
=======
167
-
[Object.keys(user)](mdn:js/Object/keys) also ignores them. That's a part of the general "hiding symbolic properties" principle. If another script or a library loops over our object, it won't unexpectedly access a symbolic property.
168
-
>>>>>>> 8d04d0d2db97276dbb2b451c30a7bd3e05d65831
164
+
همچنین `Object.keys(user)` هم آنها را نادیده میگیرد. این بخشی از اصل کلی «مخفیسازی ویژگیهای سمبلی» است. اگر یک اسکریپت یا کتابخانه دیگر در شیء ما حلقه بزند، به تصادفی به ویژگی سمبلی ما دسترسی نخواهد داشت.
169
165
170
166
در مقابل، [Object.assign](mdn:js/Object/assign) هم ویژگیهای رشته و هم سمبل را کپی میکند:
0 commit comments