Skip to content

Commit 1ba0e7b

Browse files
committed
merging all conflicts
2 parents 47df4fa + 1edb0a3 commit 1ba0e7b

23 files changed

Lines changed: 243 additions & 17 deletions

File tree

1-js/01-getting-started/1-intro/article.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,23 @@
4646

4747
بخاطر سپردن این نام‌ها مفید هستند، چراکه در مقالات مختلف به آنها بر خواهید خورد، همینطور زمانیکه ما در این آموزش برای نمونه می‌گوییم ویژگی X توسط موتور **V8** پشتیبانی می‌شود، یعنی به احتمال زیاد در مرورگرهای کروم و اپرا پشتیبانی خواهد شد.
4848

49+
<<<<<<< HEAD
4950

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
5056
5157
**موتورها** **چگونه کار** **می‌کنند**
5258

5359
موتورها پیچیده هستند، ولی اساس آنها ساده است.
5460

61+
<<<<<<< HEAD
5562
۱. موتور در ابتدا اِسکریپت را می‌خواند (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
5666
5767
۲. سپس آن را به زبان ماشین ترجمه می‌کند (Compile).
5868

@@ -64,23 +74,41 @@
6474

6575

6676

77+
<<<<<<< HEAD
6778
## جاوا اِسکریپت در مرورگر چه توانایی‌هایی دارد ؟
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
6882
6983

7084

7185
جاوا اِسکریپت مدرن زبانی‌ست امن. این زبان اجازه دسترسی در سطوح پایین مانند درسترسی به حافظه (Memory) و پردازنده (CPU) را نمی‌دهد، چراکه از ابتدا برای مرورگرها (که نیازی به این موراد ندارند) ساخته شده بود.
7286

7387

7488

89+
<<<<<<< HEAD
7590
قابلیت‌های جاوا اِسکریپت کاملا به محیطی که در آن اجرا می‌شود بستگی دارد. برای نمونه با جاوا اِسکریپت در [Node.JS](https://wikipedia.org/wiki/Node.js) می‌توان عملیات خواندن و نوشتن (Read/Write) روی فایل‌ها را انجام داد، و یا در شبکه درخواست‌هایی ارسال و دریافت کرد، و دیگر موارد.
7691

7792

7893

7994
در مرورگر جاوا اِسکریپت می‌تواند تمامی تعمالات لازم با کاربر و وب‌سِرور را انجام دهد.
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
80104
81105

82106

107+
<<<<<<< HEAD
83108
برای نمونه جاوا اِسکریپت در مرورگر می‌تواند :
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
84112
85113

86114

@@ -154,15 +182,23 @@
154182

155183
## زبان‌هایی فراتر از جاوا اِسکریپت
156184

185+
<<<<<<< HEAD
157186

187+
=======
188+
That said, JavaScript can be used to create servers, mobile applications, etc.
189+
>>>>>>> 1edb0a38330b54d2e1916f5193fc043e6fbbea78
158190
159191
سینتَکس (Syntax) جاوا اِسکریپت مورد نیاز هر کسی نیست و اشخاص مختلف به قابلیت‌های متفاوتی نیاز دارند. چراکه نیازمندی‌های هر پروژه متفاوت است.
160192

161193

162194

163195
اخیرا تعداد زیادی زبان بوجود آمده‌اند که به جاوا اِسکریپت تبدیل (Transpile) شده، پیش از آنکه جاوا اِسکریپت در مرورگر اجرا شود.
164196

197+
<<<<<<< HEAD
165198

199+
=======
200+
So, recently a plethora of new languages appeared, which are *transpiled* (converted) to JavaScript before they run in the browser.
201+
>>>>>>> 1edb0a38330b54d2e1916f5193fc043e6fbbea78
166202
167203
نمونه‌هایی از این زبان‌ها :
168204

@@ -172,6 +208,7 @@
172208
- [Dart](https://www.dartlang.org/) : که زبانی مستقل با موتور مربوط به خود بوده و در محیط‌های غیر مرورگری (مانند نرم‌افزارهای موبایل) کار می‌کند. این زبان در ابتدا توسط گوگل معرفی شد تا جایگزینی برای جاوا اِسکریپت باشد.
173209
- [Brython](https://brython.info/) یک ترانسپایلر پایتون به جاوا اسکریپت است که توسعه دهندگان را قادر می سازد برنامه هایی به زبان پایتون خالص بدون جاوا اسکریپت بنویسند.
174210

211+
<<<<<<< HEAD
175212
## خلاصه
176213

177214
- [CoffeeScript](https://coffeescript.org/) یک «syntactic sugar(سینتکس راحت‌تر)» برای جاوااسکریپت است. این زبان سینتکس کوتاه‌تری را معرفی می‌کند که به ما اجازه نوشتن کدی تمیزتر و دقیق‌تر را می‌دهد. معمولا، توسعه‌دهندگان زبان Ruby آن را دوست دارند.
@@ -180,6 +217,16 @@
180217
- [Dart](https://www.dartlang.org/) یک زبان مستقل است که موتور خود را دارد که در محیط‌های غیر مرورگر اجرا می‌شود (مانند اپ‌های موبایل) اما می‌تواند به جاوااسکریپت هم ترجمه شود. توسط گوگل توسعه داده شده است.
181218
- [Brython](https://brython.info/) یک مترجم پایتون به جاوااسکریپت است که نوشتن یک برنامه به طور کامل در زبان پایتون را بدون جاوااسکریپت مقدور می‌سازد.
182219
- [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
183230
184231
- جاوا اِسکریپت در ابتدا برای مرورگرها ساخته شده بود ولی در حال حاضر در محیط‌های متفاوتی قابلیت اجرا دارد.
185232
- جاوا اِسکریپت در شرایط حاضر موقعیت مشخص و منحصر بفردی در زبان‌های تحت مرورگرها دارد که تطابق کاملی با HTML و CSS را دارا می‌باشد.

1-js/02-first-steps/07-type-conversions/article.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,11 @@ alert(age); // NaN, conversion failed
7272
|`undefined`|`NaN`|
7373
|`null`|`0`|
7474
|<code>true&nbsp;and&nbsp;false</code> | `1` and `0` |
75+
<<<<<<< HEAD
7576
| `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
7680
7781
Examples:
7882

@@ -146,9 +150,13 @@ alert( Boolean(" ") ); // spaces, also true (any non-empty string is true)
146150
|`undefined`|`NaN`|
147151
|`null`|`0`|
148152
|<code>true&nbsp;/&nbsp;false</code> | `1 / 0` |
153+
<<<<<<< HEAD
149154
| `string` | فاصله‌های خالی ابتدا و انتها حذف می‌شوند. اگر رشته‌ی باقی مانده خالی باشد نتیجه `0` خواهد بود. در غیر اینصورت عدد موجود در رشته کاراکترها خوانده خواهد شد. همینطور اگر خطایی رخ دهد نتیجه `NaN` خواهد بود. |
150155
151156
**`تبدیل به 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`. |
159+
>>>>>>> 1edb0a38330b54d2e1916f5193fc043e6fbbea78
152160
153161
این تبدیل از این قوانین پیروی می‌کند :
154162

1-js/02-first-steps/08-operators/article.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,18 +194,32 @@ alert( +apples + +oranges ); // 5
194194
| اولویت | نام | علامت |
195195
|------------|------|------|
196196
| ... | ... | ... |
197+
<<<<<<< HEAD
197198
| 15 | جمع یگانه | `+` |
198199
| 15 | تفریق یگانه | `-` |
199200
| 14 | بتوان رساندن | `**` |
200201
| 13 | ضرب | `*` |
201202
| 13 | تقسیم | `/` |
202203
| 12 | جمع | `+` |
203204
| 12 | تفریق | `-` |
205+
=======
206+
| 14 | unary plus | `+` |
207+
| 14 | unary negation | `-` |
208+
| 13 | exponentiation | `**` |
209+
| 12 | multiplication | `*` |
210+
| 12 | division | `/` |
211+
| 11 | addition | `+` |
212+
| 11 | subtraction | `-` |
213+
>>>>>>> 1edb0a38330b54d2e1916f5193fc043e6fbbea78
204214
| ... | ... | ... |
205215
| 2 | مقداردهی | `=` |
206216
| ... | ... | ... |
207217

218+
<<<<<<< HEAD
208219
همانطور که می‌بینیم «عملگر + یگانه» اولویت `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
209223
210224
## مقداردهی
211225
@@ -303,9 +317,13 @@ alert( n ); // 14
303317
```js run
304318
let n = 2;
305319
306-
n *= 3 + 5;
320+
n *= 3 + 5; // right part evaluated first, same as n *= 8
307321
322+
<<<<<<< HEAD
308323
alert( n ); // 16 (یکسان است n *= 8، قسمت سمت راست اول ارزیابی می‌شود)
324+
=======
325+
alert( n ); // 16
326+
>>>>>>> 1edb0a38330b54d2e1916f5193fc043e6fbbea78
309327
```
310328
311329
## عملگر افزایش/کاهش

1-js/02-first-steps/12-nullish-coalescing-operator/article.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,11 @@ alert(height ?? 100); // 0
106106
107107
## اولویت
108108
109+
<<<<<<< HEAD
109110
اولویت عملگر `??` برابر با عملگر `||` است. اولویت آن‌ها در [جدول 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
110114
111115
این یعنی که درست مانند `||`، عملگر nullish coalescing `??` قبل از `=` و `?` ارزیابی می‌شود، اما بعد از بیشتر عملیات‌ها مانند `+`، `-` ارزیابی می‌شود.
112116

1-js/02-first-steps/15-function-basics/article.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function showMessage() {
2424

2525
```js
2626
function name(parameter1, parameter2, ... parameterN) {
27-
...body...
27+
// body
2828
}
2929
```
3030

@@ -206,7 +206,17 @@ function showMessage(from, *!*text = "no text given"*/!*) {
206206
showMessage("Ann"); // Ann: no text given
207207
```
208208
209+
<<<<<<< HEAD
209210
حالا اگر پارامتر `text` پاس داده نشود، مقدار `"no text given"` را می‌گیرد.
211+
=======
212+
Now if the `text` parameter is not passed, it will get the value `"no text given"`.
213+
214+
The default value also jumps in if the parameter exists, but strictly equals `undefined`, like this:
215+
216+
```js
217+
showMessage("Ann", undefined); // Ann: no text given
218+
```
219+
>>>>>>> 1edb0a38330b54d2e1916f5193fc043e6fbbea78
210220
211221
اینجا `"no text given"` یک رشته است، اما می‌تواند عبارت پیچیده‌تری باشد، که تنها در حالتی ارزیابی و مقداردهی می‌شود که پارامتری وجود نداشته باشد. بنابراین این هم ممکن است:
212222

1-js/03-code-quality/05-testing-mocha/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ So, the development is *iterative*. We write the spec, implement it, make sure t
7979

8080
Let's see this development flow in our practical case.
8181

82-
The first step is already complete: we have an initial spec for `pow`. Now, before making the implementation, let's use few JavaScript libraries to run the tests, just to see that they are working (they will all fail).
82+
The first step is already complete: we have an initial spec for `pow`. Now, before making the implementation, let's use a few JavaScript libraries to run the tests, just to see that they are working (they will all fail).
8383

8484
## The spec in action
8585

1-js/04-object-basics/09-object-toprimitive/article.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,13 @@ alert(user + 500); // hint: default -> 1500
137137

138138
اگر `Symbol.toPrimitive` وجود نداشته باشد، سپس جاوااسکریپت سعی می‌کند که متدهای `toString` و `valueOf` را پیدا کند:
139139

140+
<<<<<<< HEAD
140141
- برای جزء "string": `toString` و اگر این متد وجود نداشت، سپس `valueOf` (پس `toString` برای تبدیل‌های رشته‌ای اولویت دارد).
141142
- برای بقیه جزءها: `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
142147
143148
متدهای `toString` و `valueOf` از زمان‌های گذشته وجود دارند. آن‌ها سمبل نیستند (سمبل‌ها انقدر قدیمی نیستند) بلکه متدهای «معمولی» هستند که اسمی رشته‌ای دارد. آن‌ها راهی جایگزین برای پیاده‌سازی تبدیل به «سبک قدیمی» را فراهم می‌کنند.
144149

0 commit comments

Comments
 (0)