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/01-getting-started/1-intro/article.md
-47Lines changed: 0 additions & 47 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -46,23 +46,13 @@
46
46
47
47
بخاطر سپردن این نامها مفید هستند، چراکه در مقالات مختلف به آنها بر خواهید خورد، همینطور زمانیکه ما در این آموزش برای نمونه میگوییم ویژگی X توسط موتور **V8** پشتیبانی میشود، یعنی به احتمال زیاد در مرورگرهای کروم و اپرا پشتیبانی خواهد شد.
48
48
49
-
<<<<<<< HEAD
50
49
51
-
=======
52
-
1. The engine (embedded if it's a browser) reads ("parses") the script.
53
-
2. Then it converts ("compiles") the script to machine code.
54
-
3. And then the machine code runs, pretty fast.
55
-
>>>>>>> 1edb0a38330b54d2e1916f5193fc043e6fbbea78
56
50
57
51
**موتورها****چگونه کار****میکنند**
58
52
59
53
موتورها پیچیده هستند، ولی اساس آنها ساده است.
60
54
61
-
<<<<<<< HEAD
62
55
۱. موتور در ابتدا اِسکریپت را میخواند (Parse).
63
-
=======
64
-
Modern JavaScript is a "safe" programming language. It does not provide low-level access to memory or the CPU, because it was initially created for browsers which do not require it.
65
-
>>>>>>> 1edb0a38330b54d2e1916f5193fc043e6fbbea78
66
56
67
57
۲. سپس آن را به زبان ماشین ترجمه میکند (Compile).
68
58
@@ -74,41 +64,23 @@ Modern JavaScript is a "safe" programming language. It does not provide low-leve
74
64
75
65
76
66
77
-
<<<<<<< HEAD
78
67
## جاوا اِسکریپت در مرورگر چه تواناییهایی دارد ؟
79
-
=======
80
-
JavaScript's abilities in the browser are limited to protect the user's safety. The aim is to prevent an evil webpage from accessing private information or harming the user's data.
81
-
>>>>>>> 1edb0a38330b54d2e1916f5193fc043e6fbbea78
82
68
83
69
84
70
85
71
جاوا اِسکریپت مدرن زبانیست امن. این زبان اجازه دسترسی در سطوح پایین مانند درسترسی به حافظه (Memory) و پردازنده (CPU) را نمیدهد، چراکه از ابتدا برای مرورگرها (که نیازی به این موراد ندارند) ساخته شده بود.
86
72
87
73
88
74
89
-
<<<<<<< HEAD
90
75
قابلیتهای جاوا اِسکریپت کاملا به محیطی که در آن اجرا میشود بستگی دارد. برای نمونه با جاوا اِسکریپت در [Node.JS](https://wikipedia.org/wiki/Node.js) میتوان عملیات خواندن و نوشتن (Read/Write) روی فایلها را انجام داد، و یا در شبکه درخواستهایی ارسال و دریافت کرد، و دیگر موارد.
91
76
92
77
93
78
94
79
در مرورگر جاوا اِسکریپت میتواند تمامی تعمالات لازم با کاربر و وبسِرور را انجام دهد.
95
-
=======
96
-
There are ways to interact with the camera/microphone and other devices, but they require a user's explicit permission. So a JavaScript-enabled page may not sneakily enable a web-camera, observe the surroundings and send the information to the [NSA](https://en.wikipedia.org/wiki/National_Security_Agency).
97
-
- Different tabs/windows generally do not know about each other. Sometimes they do, for example when one window uses JavaScript to open the other one. But even in this case, JavaScript from one page may not access the other page if they come from different sites (from a different domain, protocol or port).
98
-
99
-
This is called the "Same Origin Policy". To work around that, *both pages* must agree for data exchange and must contain special JavaScript code that handles it. We'll cover that in the tutorial.
100
-
101
-
This limitation is, again, for the user's safety. A page from `http://anysite.com` which a user has opened must not be able to access another browser tab with the URL `http://gmail.com`, for example, and steal information from there.
102
-
- JavaScript can easily communicate over the net to the server where the current page came from. But its ability to receive data from other sites/domains is crippled. Though possible, it requires explicit agreement (expressed in HTTP headers) from the remote side. Once again, that's a safety limitation.
103
-
>>>>>>> 1edb0a38330b54d2e1916f5193fc043e6fbbea78
104
80
105
81
106
82
107
-
<<<<<<< HEAD
108
83
برای نمونه جاوا اِسکریپت در مرورگر میتواند :
109
-
=======
110
-
Such limitations do not exist if JavaScript is used outside of the browser, for example on a server. Modern browsers also allow plugins/extensions which may ask for extended permissions.
111
-
>>>>>>> 1edb0a38330b54d2e1916f5193fc043e6fbbea78
112
84
113
85
114
86
@@ -182,23 +154,15 @@ Such limitations do not exist if JavaScript is used outside of the browser, for
182
154
183
155
## زبانهایی فراتر از جاوا اِسکریپت
184
156
185
-
<<<<<<< HEAD
186
157
187
-
=======
188
-
That said, JavaScript can be used to create servers, mobile applications, etc.
189
-
>>>>>>> 1edb0a38330b54d2e1916f5193fc043e6fbbea78
190
158
191
159
سینتَکس (Syntax) جاوا اِسکریپت مورد نیاز هر کسی نیست و اشخاص مختلف به قابلیتهای متفاوتی نیاز دارند. چراکه نیازمندیهای هر پروژه متفاوت است.
192
160
193
161
194
162
195
163
اخیرا تعداد زیادی زبان بوجود آمدهاند که به جاوا اِسکریپت تبدیل (Transpile) شده، پیش از آنکه جاوا اِسکریپت در مرورگر اجرا شود.
196
164
197
-
<<<<<<< HEAD
198
165
199
-
=======
200
-
So, recently a plethora of new languages appeared, which are *transpiled* (converted) to JavaScript before they run in the browser.
201
-
>>>>>>> 1edb0a38330b54d2e1916f5193fc043e6fbbea78
202
166
203
167
نمونههایی از این زبانها :
204
168
@@ -208,7 +172,6 @@ So, recently a plethora of new languages appeared, which are *transpiled* (conve
208
172
-[Dart](https://www.dartlang.org/) : که زبانی مستقل با موتور مربوط به خود بوده و در محیطهای غیر مرورگری (مانند نرمافزارهای موبایل) کار میکند. این زبان در ابتدا توسط گوگل معرفی شد تا جایگزینی برای جاوا اِسکریپت باشد.
209
173
-[Brython](https://brython.info/) یک ترانسپایلر پایتون به جاوا اسکریپت است که توسعه دهندگان را قادر می سازد برنامه هایی به زبان پایتون خالص بدون جاوا اسکریپت بنویسند.
210
174
211
-
<<<<<<< HEAD
212
175
## خلاصه
213
176
214
177
-[CoffeeScript](https://coffeescript.org/) یک «syntactic sugar(سینتکس راحتتر)» برای جاوااسکریپت است. این زبان سینتکس کوتاهتری را معرفی میکند که به ما اجازه نوشتن کدی تمیزتر و دقیقتر را میدهد. معمولا، توسعهدهندگان زبان Ruby آن را دوست دارند.
@@ -217,16 +180,6 @@ So, recently a plethora of new languages appeared, which are *transpiled* (conve
217
180
-[Dart](https://www.dartlang.org/) یک زبان مستقل است که موتور خود را دارد که در محیطهای غیر مرورگر اجرا میشود (مانند اپهای موبایل) اما میتواند به جاوااسکریپت هم ترجمه شود. توسط گوگل توسعه داده شده است.
218
181
-[Brython](https://brython.info/) یک مترجم پایتون به جاوااسکریپت است که نوشتن یک برنامه به طور کامل در زبان پایتون را بدون جاوااسکریپت مقدور میسازد.
219
182
-[Kotlin](https://kotlinlang.org/docs/reference/js-overview.html) یک زبان برنامهنویسی مدرن، مختصر و امن است که میتواند مرورگر یا Node را مورد هدف قرار دهد.
220
-
=======
221
-
-[CoffeeScript](https://coffeescript.org/) is "syntactic sugar" for JavaScript. It introduces shorter syntax, allowing us to write clearer and more precise code. Usually, Ruby devs like it.
222
-
-[TypeScript](https://www.typescriptlang.org/) is concentrated on adding "strict data typing" to simplify the development and support of complex systems. It is developed by Microsoft.
223
-
-[Flow](https://flow.org/) also adds data typing, but in a different way. Developed by Facebook.
224
-
-[Dart](https://www.dartlang.org/) is a standalone language that has its own engine that runs in non-browser environments (like mobile apps), but also can be transpiled to JavaScript. Developed by Google.
225
-
-[Brython](https://brython.info/) is a Python transpiler to JavaScript that enables the writing of applications in pure Python without JavaScript.
226
-
-[Kotlin](https://kotlinlang.org/docs/reference/js-overview.html) is a modern, concise and safe programming language that can target the browser or Node.
227
-
228
-
There are more. Of course, even if we use one of these transpiled languages, we should also know JavaScript to really understand what we're doing.
229
-
>>>>>>> 1edb0a38330b54d2e1916f5193fc043e6fbbea78
230
183
231
184
- جاوا اِسکریپت در ابتدا برای مرورگرها ساخته شده بود ولی در حال حاضر در محیطهای متفاوتی قابلیت اجرا دارد.
232
185
- جاوا اِسکریپت در شرایط حاضر موقعیت مشخص و منحصر بفردی در زبانهای تحت مرورگرها دارد که تطابق کاملی با HTML و CSS را دارا میباشد.
|<code>true and false</code> |`1` and `0`|
75
-
<<<<<<< HEAD
76
75
|`string`| فاصلههای خالی ابتدا و انتها حذف میشوند. اگر رشتهی باقی مانده خالی باشد نتیجه `0` خواهد بود. در غیر اینصورت عدد موجود در رشته کاراکترها خوانده خواهد شد. همینطور اگر خطایی رخ دهد نتیجه `NaN` خواهد بود. |
77
-
=======
78
-
|`string`| Whitespaces (includes spaces, tabs `\t`, newlines `\n` etc.) from the start and end are removed. If the remaining string is empty, the result is `0`. Otherwise, the number is "read" from the string. An error gives `NaN`. |
79
-
>>>>>>> 1edb0a38330b54d2e1916f5193fc043e6fbbea78
80
76
81
77
Examples:
82
78
@@ -150,13 +146,9 @@ alert( Boolean(" ") ); // spaces, also true (any non-empty string is true)
150
146
|`undefined`|`NaN`|
151
147
|`null`|`0`|
152
148
|<code>true / false</code> | `1 / 0` |
153
-
<<<<<<< HEAD
154
149
| `string` | فاصلههای خالی ابتدا و انتها حذف میشوند. اگر رشتهی باقی مانده خالی باشد نتیجه `0` خواهد بود. در غیر اینصورت عدد موجود در رشته کاراکترها خوانده خواهد شد. همینطور اگر خطایی رخ دهد نتیجه `NaN` خواهد بود. |
155
150
156
151
**`تبدیل به boolean`** – در عملگرهای منطقی رخ میدهد. از طریق `Boolean(value)` قابل انجام است.
157
-
=======
158
-
| `string` | The string is read "as is", whitespaces (includes spaces, tabs `\t`, newlines `\n` etc.) from both sides are ignored. An empty string becomes `0`. An error gives `NaN`. |
همانطور که میبینیم «عملگر + یگانه» اولویت `15` دارد که از عملگر جمع ( + دوگانه) با اولویت `12` بالاتر است. به همین دلیل است که در عبارت `"+apples + +oranges"` عملگرهای + یگانه پیش از علامت جمع اجرا میشوند.
220
-
=======
221
-
As we can see, the "unary plus" has a priority of`14` which is higher than the `11`of"addition" (binary plus). That's why, in the expression `"+apples + +oranges"`, unary pluses work before the addition.
222
-
>>>>>>> 1edb0a38330b54d2e1916f5193fc043e6fbbea78
208
+
همانطور که میبینیم «عملگر + یگانه» اولویت `14` دارد که از عملگر جمع ( + دوگانه) با اولویت `11` بالاتر است. به همین دلیل است که در عبارت `"+apples + +oranges"` عملگرهای + یگانه پیش از علامت جمع اجرا میشوند.
223
209
224
210
## مقداردهی
225
211
@@ -317,13 +303,9 @@ alert( n ); // 14
317
303
```js run
318
304
let n = 2;
319
305
320
-
n *= 3 + 5; // right part evaluated first, same as n *= 8
306
+
n *= 3 + 5; // بخش سمت راستی اول اجرا میشود درست مانند n *= 8
321
307
322
-
<<<<<<< HEAD
323
-
alert( n ); // 16 (یکسان است n *= 8، قسمت سمت راست اول ارزیابی میشود)
Copy file name to clipboardExpand all lines: 1-js/02-first-steps/12-nullish-coalescing-operator/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
@@ -106,11 +106,7 @@ alert(height ?? 100); // 0
106
106
107
107
## اولویت
108
108
109
-
<<<<<<< HEAD
110
-
اولویت عملگر `??` برابر با عملگر `||` است. اولویت آنها در [جدول MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence#Table) برابر با `4` است.
111
-
=======
112
-
The precedence of the `??` operator is the same as `||`. They both equal `3` in the [MDN table](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence#Table).
113
-
>>>>>>> 1edb0a38330b54d2e1916f5193fc043e6fbbea78
109
+
اولویت عملگر `??` برابر با عملگر `||` است. اولویت آنها در [جدول MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence#Table) برابر با `3` است.
114
110
115
111
این یعنی که درست مانند `||`، عملگر nullish coalescing `??` قبل از `=` و `?` ارزیابی میشود، اما بعد از بیشتر عملیاتها مانند `+`، `-` ارزیابی میشود.
Copy file name to clipboardExpand all lines: 1-js/02-first-steps/15-function-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
@@ -206,17 +206,13 @@ function showMessage(from, *!*text = "no text given"*/!*) {
206
206
showMessage("Ann"); // Ann: no text given
207
207
```
208
208
209
-
<<<<<<< HEAD
210
209
حالا اگر پارامتر `text` پاس داده نشود، مقدار `"no text given"` را میگیرد.
211
-
=======
212
-
Now if the `text` parameter is not passed, it will get the value `"no text given"`.
213
210
214
-
The default value also jumps in if the parameter exists, but strictly equals `undefined`, like this:
211
+
همچنین اگر پارامتر وجود داشته باشد نیز ممکن است مقدار پیشفرض قرار بگیرد، در صورتی که برابر با `undefined` باشد، مانند زیر:
215
212
216
213
```js
217
214
showMessage("Ann", undefined); // Ann: no text given
218
215
```
219
-
>>>>>>> 1edb0a38330b54d2e1916f5193fc043e6fbbea78
220
216
221
217
اینجا `"no text given"` یک رشته است، اما میتواند عبارت پیچیدهتری باشد، که تنها در حالتی ارزیابی و مقداردهی میشود که پارامتری وجود نداشته باشد. بنابراین این هم ممکن است:
همانطور که از کد میبینیم، با توجه به تبدیل، `user` به رشتهای خودتعریفکننده یا مقداری پول تبدیل میشود. متد `user[Symbol.toPrimitive]` به تنهایی تمام موارد تبدیل را به عهده میگیرد.
134
134
135
-
136
135
## متد toString/valueOf
137
136
138
137
اگر `Symbol.toPrimitive` وجود نداشته باشد، سپس جاوااسکریپت سعی میکند که متدهای `toString` و `valueOf` را پیدا کند:
139
138
140
-
<<<<<<< HEAD
141
-
- برای جزء "string": `toString` و اگر این متد وجود نداشت، سپس `valueOf` (پس `toString` برای تبدیلهای رشتهای اولویت دارد).
139
+
- برای جزء `"string"`: `toString` و اگر این متد وجود نداشت، سپس `valueOf` (پس `toString` برای تبدیلهای رشتهای اولویت دارد).
142
140
- برای بقیه جزءها: `valueOf` و اگر این متد وجود نداشت، سپس `toString` (پس `valueOf` برای ریاضیات اولویت دارد).
143
-
=======
144
-
- For the `"string"` hint: call `toString` method, and if it doesn't exist or if it returns an object instead of a primitive value, then call `valueOf` (so `toString` has the priority for string conversions).
145
-
- For other hints: call `valueOf`, and if it doesn't exist or if it returns an object instead of a primitive value, then call `toString` (so `valueOf` has the priority for maths).
146
-
>>>>>>> 1edb0a38330b54d2e1916f5193fc043e6fbbea78
147
141
148
142
متدهای `toString` و `valueOf` از زمانهای گذشته وجود دارند. آنها سمبل نیستند (سمبلها انقدر قدیمی نیستند) بلکه متدهای «معمولی» هستند که اسمی رشتهای دارد. آنها راهی جایگزین برای پیادهسازی تبدیل به «سبک قدیمی» را فراهم میکنند.
0 commit comments