Skip to content

Commit aae3205

Browse files
committed
merging all conflicts
2 parents 2ebe754 + 62299ed commit aae3205

15 files changed

Lines changed: 82 additions & 17 deletions

File tree

1-js/02-first-steps/01-hello-world/article.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,13 @@
4545
تگ `<script>` تعدادی attributes (صفات) دارد که امروزه کمتر از آنها استفاده می‌شود، ولی ممکن است در کدهای قدیمی همچنان آنها را ببینید :
4646

4747

48+
<<<<<<< HEAD
4849
صفت `type` : <code>&lt;script <u>type</u>=...&gt;</code>
4950
: نسخه قدیمی HTML یعنی HTML4 نیازمند تعیین `type` در تگ `<script>` بود. معمولا مقدار آن `type=text/javascript` بود. در حال حاضر دیگر این مورد الزامی نیست.
51+
=======
52+
The `type` attribute: <code>&lt;script <u>type</u>=...&gt;</code>
53+
: The old HTML standard, HTML4, required a script to have a `type`. Usually it was `type="text/javascript"`. It's not required anymore. Also, the modern HTML standard totally changed the meaning of this attribute. Now, it can be used for JavaScript modules. But that's an advanced topic, we'll talk about modules in another part of the tutorial.
54+
>>>>>>> 62299ed853674c4fd1427cd310516d5535bce648
5055
5156
صفت `language` : <code>&lt;script <u>language</u>=...&gt;</code>
5257
: مقصود از این صفت تعیین زبان اسکریپت است. از آنجایی که جاوا اسکریپت زبان پیش‌فرض است، نیازی به تعیین آن نیست.

1-js/04-object-basics/01-object/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ user.likes birds = true
103103

104104
JavaScript doesn't understand that. It thinks that we address `user.likes`, and then gives a syntax error when comes across unexpected `birds`.
105105

106-
The dot requires the key to be a valid variable identifier. That implies: contains no spaces, doesn't start with a digit and doesn't include special characters (`$` и `_` are allowed).
106+
The dot requires the key to be a valid variable identifier. That implies: contains no spaces, doesn't start with a digit and doesn't include special characters (`$` and `_` are allowed).
107107

108108
There's an alternative "square bracket notation" that works with any string:
109109

1-js/05-data-types/02-number/article.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,11 @@ alert( isFinite(num) );
318318

319319
یک تابع از پیش آماده شده‌ی خاص [Object.is](mdn:js/Object/is) که مقادیر را مثل `===` مقایسه میکند، اما برای دو حالت مرزی قابل اعتمادتر است.
320320

321+
<<<<<<< HEAD
321322
۱. با `NaN` کار میکند: `Object.is(NaN, NaN) === true`، که چیز خوبیست.
323+
=======
324+
There is a special built-in method [`Object.is`](mdn:js/Object/is) that compares values like `===`, but is more reliable for two edge cases:
325+
>>>>>>> 62299ed853674c4fd1427cd310516d5535bce648
322326
323327
۲. مقادیر `0` و `-0` متفاوت هستند: `Object.is(0, -0) === false`، به ندرت اهمیت دارد، اما این مقادیر در اصل متفاوتند.
324328

@@ -412,7 +416,13 @@ alert( Math.pow(2, 10) ); // دو به توان ده = 1024
412416
413417
- `num.toString(base)` یک عدد را به یک رشته‌ی حرفی در سیستم عددی با پایه داده شده تبدیل می‌کند.
414418
419+
<<<<<<< HEAD
415420
برای تبدیل مقادیری مثل `12pt` و `100px` به یک عدد:
421+
=======
422+
- Can write numbers directly in hex (`0x`), octal (`0o`) and binary (`0b`) systems.
423+
- `parseInt(str, base)` parses the string `str` into an integer in numeral system with given `base`, `2 ≤ base ≤ 36`.
424+
- `num.toString(base)` converts a number to a string in the numeral system with the given `base`.
425+
>>>>>>> 62299ed853674c4fd1427cd310516d5535bce648
416426
417427
- `parseInt/parseFloat` را برای تبدیلات ساده استفاده کنید که یک عدد را از یک رشته‌ی حرفی می‌خواند و سپس مقداری که قبل از بروز خطا خوانده‌ست را برمی‌گرداند.
418428

1-js/06-advanced-functions/01-recursion/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ list.next.next.next = { value: 4 };
462462
list.next.next.next.next = null;
463463
```
464464
465-
Here we can even more clearer see that there are multiple objects, each one has the `value` and `next` pointing to the neighbour. The `list` variable is the first object in the chain, so following `next` pointers from it we can reach any element.
465+
Here we can even more clearly see that there are multiple objects, each one has the `value` and `next` pointing to the neighbour. The `list` variable is the first object in the chain, so following `next` pointers from it we can reach any element.
466466
467467
The list can be easily split into multiple parts and later joined back:
468468

1-js/06-advanced-functions/02-rest-parameters-spread/article.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,51 @@ But there's a subtle difference between `Array.from(obj)` and `[...obj]`:
225225
So, for the task of turning something into an array, `Array.from` tends to be more universal.
226226
227227
228+
## Get a new copy of an object/array
229+
230+
Remember when we talked about `Object.assign()` [in the past](https://javascript.info/symbol#symbols-are-skipped-by-for-in)?
231+
232+
It is possible to do the same thing with the spread operator!
233+
234+
```
235+
let arr = [1, 2, 3];
236+
let arrCopy = [...arr]; // spread the array into a list of parameters
237+
// then put the result into a new array
238+
239+
// do the arrays have the same contents?
240+
alert(JSON.stringify(arr) === JSON.stringify(arrCopy)); // true
241+
242+
// are the arrays equal?
243+
alert(arr === arrCopy); // false (not same reference)
244+
245+
// modifying our initial array does not modify the copy:
246+
arr.push(4);
247+
alert(arr); // 1, 2, 3, 4
248+
alert(arrCopy); // 1, 2, 3
249+
```
250+
251+
Note that it is possible to do the same thing to make a copy of an object:
252+
253+
```
254+
let obj = { a: 1, b: 2, c: 3 };
255+
let objCopy = { ...obj }; // spread the object into a list of parameters
256+
// then return the result in a new object
257+
258+
// do the objects have the same contents?
259+
alert(JSON.stringify(obj) === JSON.stringify(objCopy)); // true
260+
261+
// are the objects equal?
262+
alert(obj === objCopy); // false (not same reference)
263+
264+
// modifying our initial object does not modify the copy:
265+
obj.d = 4;
266+
alert(JSON.stringify(obj)); // {"a":1,"b":2,"c":3,"d":4}
267+
alert(JSON.stringify(objCopy)); // {"a":1,"b":2,"c":3}
268+
```
269+
270+
This way of copying an object is much shorter than `let objCopy = Object.assign({}, obj);` or for an array `let arrCopy = Object.assign([], arr);` so we prefer to use it whenever we can.
271+
272+
228273
## Summary
229274
230275
When we see `"..."` in the code, it is either rest parameters or the spread syntax.

1-js/06-advanced-functions/03-closure/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ Here's a little bit longer code:
182182
Rectangles on the right-hand side demonstrate how the global Lexical Environment changes during the execution:
183183

184184
1. When the script starts, the Lexical Environment is pre-populated with all declared variables.
185-
- Initially, they are in the "Uninitialized" state. That's a special internal state, it means that the engine knows about the variable, but won't allow to use it before `let`. It's almost the same as if the variable didn't exist.
185+
- Initially, they are in the "Uninitialized" state. That's a special internal state, it means that the engine knows about the variable, but it cannot be referenced until it has been declared with `let`. It's almost the same as if the variable didn't exist.
186186
2. Then `let phrase` definition appears. There's no assignment yet, so its value is `undefined`. We can use the variable since this moment.
187187
3. `phrase` is assigned a value.
188188
4. `phrase` changes the value.

1-js/08-prototypes/04-prototype-methods/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ This call makes a truly exact copy of `obj`, including all properties: enumerabl
6565

6666
## Brief history
6767

68-
If we count all the ways to manage `[[Prototype]]`, there are a lot! Many ways to do the same!
68+
If we count all the ways to manage `[[Prototype]]`, there are a lot! Many ways to do the same thing!
6969

7070
Why?
7171

2-ui/1-document/11-coordinates/1-find-point-coordinates/solution.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Outer corners
22

3-
Outer corners are basically what we get from [elem.getBoundingClientRect()](https://developer.mozilla.org/en-US/docs/DOM/element.getBoundingClientRect).
3+
Outer corners are basically what we get from [elem.getBoundingClientRect()](https://developer.mozilla.org/en-US/docs/DOM/element.getBoundingClientRect).
44

55
Coordinates of the upper-left corner `answer1` and the bottom-right corner `answer2`:
66

2-ui/2-events/02-bubbling-and-capturing/article.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,15 @@ There's a property `event.eventPhase` that tells us the number of the phase on w
186186

187187
The event handling process:
188188

189+
<<<<<<< HEAD
189190
- When an event happens -- the most nested element where it happens gets labeled as the "target element" (`event.target`).
190191
- Then the event first moves from the document root down to the `event.target`, calling handlers assigned with `addEventListener(...., true)` on the way.
191192
- Then the event moves from `event.target` up to the root, calling handlers assigned using `on<event>` and `addEventListener` without the 3rd argument or with the 3rd argument `false`.
193+
=======
194+
- Then the event moves down from the document root to `event.target`, calling handlers assigned with `addEventListener(..., true)` on the way (`true` is a shorthand for `{capture: true}`).
195+
- Then handlers are called on the target element itself.
196+
- Then the event bubbles up from `event.target` up to the root, calling handlers assigned using `on<event>` and `addEventListener` without the 3rd argument or with the 3rd argument `false/{capture:false}`.
197+
>>>>>>> 62299ed853674c4fd1427cd310516d5535bce648
192198
193199
Each handler can access `event` object properties:
194200

2-ui/2-events/04-default-browser-action/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ The property `event.defaultPrevented` is `true` if the default action was preven
9999

100100
There's an interesting use case for it.
101101

102-
You remember in the chapter <info:bubbling-and-capturing> we talked about `event.stopPropagation()` and why stopping bubbling is bad?
102+
You remember in the chapter <info:bubbling-and-capturing> we talked about `event.stopPropagation()` and why stopping bubbling is bad?
103103

104104
Sometimes we can use `event.defaultPrevented` instead, to signal other event handlers that the event was handled.
105105

0 commit comments

Comments
 (0)