Skip to content

Commit 26dc52f

Browse files
committed
merging all conflicts
2 parents 52f7a4b + 3c934b5 commit 26dc52f

7 files changed

Lines changed: 42 additions & 13 deletions

File tree

1-js/02-first-steps/16-function-expressions/article.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ let sayHi = function() {
3434

3535
## تابع یک مقدار است
3636

37+
<<<<<<< HEAD
3738
بیایید تکرار کنیم: مهم نیست که تابع چگونه ساخته شده است، یک تابع همیشه یک مقدار است. هر دو مثال بالا تابعی را درون متغیر `sayHi` ذخیره می‌کنند.
39+
=======
40+
Let's reiterate: no matter how the function is created, a function is a value. Both examples above store a function in the `sayHi` variable.
41+
>>>>>>> 3c934b5a46a76861255e3a4f29da6fd54ab05c8c
3842
3943
ما حتی می‌توانیم آن مقدار را با استفاده از `alert` چاپ کنیم:
4044

1-js/04-object-basics/08-symbol/article.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,11 @@ for (let key in user) alert(key); // name, age (بدون سمبل)
161161
alert( "به طور مستقیم: " + user[id] );
162162
```
163163

164+
<<<<<<< HEAD
164165
همچنین `Object.keys(user)` هم آنها را نادیده می‌گیرد. این بخشی از اصل کلی «مخفی‌سازی ویژگی‌های سمبلی» است. اگر یک اسکریپت یا کتابخانه دیگر در شیء ما حلقه بزند، به تصادفی به ویژگی سمبلی ما دسترسی نخواهد داشت.
166+
=======
167+
[Object.keys(user)](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/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+
>>>>>>> 3c934b5a46a76861255e3a4f29da6fd54ab05c8c
165169
166170
در مقابل، [Object.assign](mdn:js/Object/assign) هم ویژگی‌های رشته و هم سمبل را کپی می‌کند:
167171

1-js/05-data-types/12-json/article.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ alert(user); // {name: "John", age: 30}
2727

2828
## متد JSON.stringify
2929

30+
<<<<<<< HEAD
3031
[JSON](http://fa.wikipedia.org/wiki/جی%E2%80%8Cسان) (نشانه‌گذاری شیء جاوااسکریپت، جِی‌سان) یک فرمت کلی برای نمایش مقدارها و شیءها است. جِی‌سان در استاندارد [RFC 4627](http://tools.ietf.org/html/rfc4627) شرح داده شده است. در ابتدا برای جاوااسکریپت ساخته شد اما بسیاری از زبان‌های دیگر هم کتابخانه‌هایی برای بکاربردن آن دارند. پس هنگامی که سمت کاربر سایت از جاوااسکریپت و سمت سرور با زبان‌های Ruby/PHP/Java/یا هر چیز دیگر نوشته شده باشد، استفاده از جی‌سان برای رد و بدل کردن داده آسان است.
32+
=======
33+
The [JSON](http://en.wikipedia.org/wiki/JSON) (JavaScript Object Notation) is a general format to represent values and objects. It is described as in [RFC 4627](https://tools.ietf.org/html/rfc4627) standard. Initially it was made for JavaScript, but many other languages have libraries to handle it as well. So it's easy to use JSON for data exchange when the client uses JavaScript and the server is written on Ruby/PHP/Java/Whatever.
34+
>>>>>>> 3c934b5a46a76861255e3a4f29da6fd54ab05c8c
3135
3236
جاوااسکریپت متدهای زیر را دارد:
3337

1-js/08-prototypes/01-prototype-inheritance/article.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,11 @@ alert( rabbit.eats ); // true (**)
5454
alert( rabbit.jumps ); // true
5555
```
5656

57+
<<<<<<< HEAD
5758
اینجا خط `(*)` شیء `animal` را به عنوان پروتوتایپ `rabbit` تنظیم می‌کند.
59+
=======
60+
Here the line `(*)` sets `animal` to be the prototype of `rabbit`.
61+
>>>>>>> 3c934b5a46a76861255e3a4f29da6fd54ab05c8c
5862
5963
سپس زمانی که `alert` سعی می‌کند تا ویژگی `rabbit.eats` `(**)` را بخواند، درون `rabbit` نیست پس جاوااسکریپت مرجع `[[Prototype]]` را دنبال می‌کند و ویژگی را درون `animal` پیدا می‌کند (از پایین به بالا نگاه کنید):
6064

@@ -287,7 +291,11 @@ for(let prop in rabbit) alert(prop); // eats سپس ،jumps
287291
*/!*
288292
```
289293

294+
<<<<<<< HEAD
290295
اگر این چیزی نیست که ما می‌خواهیم و دوست داریم که شامل ویژگی‌های به ارث‌برده‌شده نشود، یک متد درون‌ساخت [obj.hasOwnProperty(key)](mdn:js/Object/hasOwnProperty) وجود دارد: این متد اگر `obj` ویژگی خودش (نه به ارث‌برده‌شده) به نام `key` را داشته باشد `true` برمی‌گرداند.
296+
=======
297+
If that's not what we want, and we'd like to exclude inherited properties, there's a built-in method [obj.hasOwnProperty(key)](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty): it returns `true` if `obj` has its own (not inherited) property named `key`.
298+
>>>>>>> 3c934b5a46a76861255e3a4f29da6fd54ab05c8c
291299
292300
پس می‌تواند ویژگی‌های به ارث‌برده‌شده را جداسازی کنیم (یا کاری دیگر با آن‌ها کنیم):
293301

1-js/09-classes/01-class/article.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,11 @@ alert(Object.getOwnPropertyNames(User.prototype)); // sayHi ،سازنده
118118

119119
## فقط یک سینتکس برای زیباکردن(syntactic sugar) نیست
120120

121+
<<<<<<< HEAD
121122
گاهی اوقات مردم می‌گویند که `class` یک «سینتکس برای زیباکردن(syntactic sugar)» است (سینتکسی که برای خواندن ساده‌تر طراحی شده است، اما چیز جدیدی معرفی نمی‌کند)، زیرا در واقع می‌توانیم همان را بدون کلمه کلیدی `class` تعریف کنیم:
123+
=======
124+
Sometimes people say that `class` is a "syntactic sugar" (syntax that is designed to make things easier to read, but doesn't introduce anything new), because we could actually declare the same thing without using the `class` keyword at all:
125+
>>>>>>> 3c934b5a46a76861255e3a4f29da6fd54ab05c8c
122126
123127
```js run
124128
// بازنویسی کلاس کاربر در توابع خالص

5-network/05-fetch-crossorigin/article.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,10 +207,11 @@ Some time ago no one could even imagine that a webpage could make such requests.
207207

208208
So, to avoid misunderstandings, any "unsafe" request -- that couldn't be done in the old times, the browser does not make such requests right away. First, it sends a preliminary, so-called "preflight" request, to ask for permission.
209209
210-
A preflight request uses the method `OPTIONS`, no body and two headers:
210+
A preflight request uses the method `OPTIONS`, no body and three headers:
211211
212212
- `Access-Control-Request-Method` header has the method of the unsafe request.
213213
- `Access-Control-Request-Headers` header provides a comma-separated list of its unsafe HTTP-headers.
214+
- `Origin` header tells from where the request came. (such as `https://javascript.info`)
214215
215216
If the server agrees to serve the requests, then it should respond with empty body, status 200 and headers:
216217

6-data-storage/01-cookie/article.md

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -96,38 +96,42 @@ Usually, we should set `path` to the root: `path=/` to make the cookie accessibl
9696

9797
A domain defines where the cookie is accessible. In practice though, there are limitations. We can't set any domain.
9898

99-
By default, a cookie is accessible only at the domain that set it. So, if the cookie was set by `site.com`, we won't get it at `other.com`.
99+
**There's no way to let a cookie be accessible from another 2nd-level domain, so `other.com` will never receive a cookie set at `site.com`.**
100+
101+
It's a safety restriction, to allow us to store sensitive data in cookies that should be available only on one site.
100102

101-
...But what's more tricky, we also won't get the cookie at a subdomain `forum.site.com`!
103+
By default, a cookie is accessible only at the domain that set it.
104+
105+
Please note, by default a cookie is also not shared to a subdomain as well, such as `forum.site.com`.
102106

103107
```js
104-
// at site.com
108+
// if we set a cookie at site.com website...
105109
document.cookie = "user=John"
106110

107-
// at forum.site.com
111+
// ...we won't see it at forum.site.com
108112
alert(document.cookie); // no user
109113
```
110114

111-
**There's no way to let a cookie be accessible from another 2nd-level domain, so `other.com` will never receive a cookie set at `site.com`.**
115+
...But this can be changed. If we'd like to allow subdomains like `forum.site.com` to get a cookie set at `site.com`, that's possible.
112116

113-
It's a safety restriction, to allow us to store sensitive data in cookies, that should be available only on one site.
117+
For that to happen, when setting a cookie at `site.com`, we should explicitly set the `domain` option to the root domain: `domain=site.com`. Then all subdomains will see such cookie.
114118

115-
...But if we'd like to allow subdomains like `forum.site.com` to get a cookie, that's possible. When setting a cookie at `site.com`, we should explicitly set the `domain` option to the root domain: `domain=site.com`:
119+
For example:
116120

117121
```js
118122
// at site.com
119123
// make the cookie accessible on any subdomain *.site.com:
120-
document.cookie = "user=John; domain=site.com"
124+
document.cookie = "user=John; *!*domain=site.com*/!*"
121125

122126
// later
123127

124128
// at forum.site.com
125129
alert(document.cookie); // has cookie user=John
126130
```
127131

128-
For historical reasons, `domain=.site.com` (a dot before `site.com`) also works the same way, allowing access to the cookie from subdomains. That's an old notation and should be used if we need to support very old browsers.
132+
For historical reasons, `domain=.site.com` (with a dot before `site.com`) also works the same way, allowing access to the cookie from subdomains. That's an old notation and should be used if we need to support very old browsers.
129133

130-
So, the `domain` option allows to make a cookie accessible at subdomains.
134+
To summarize, the `domain` option allows to make a cookie accessible at subdomains.
131135

132136
## expires, max-age
133137

@@ -180,7 +184,7 @@ With this option, if a cookie is set by `https://site.com`, then it doesn't appe
180184
// assuming we're on https:// now
181185
// set the cookie to be secure (only accessible over HTTPS)
182186
document.cookie = "user=John; secure";
183-
```
187+
```
184188

185189
## samesite
186190

@@ -247,7 +251,7 @@ But anything more complicated, like a network request from another site or a for
247251

248252
If that's fine for you, then adding `samesite=lax` will probably not break the user experience and add protection.
249253

250-
Overall, `samesite` is a great option.
254+
Overall, `samesite` is a great option.
251255

252256
There's a drawback:
253257

0 commit comments

Comments
 (0)