Skip to content

Commit 8d0975f

Browse files
authored
Fix Conflicts 1/9/1
1 parent 6c4c77e commit 8d0975f

1 file changed

Lines changed: 0 additions & 43 deletions

File tree

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

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -330,11 +330,7 @@ alert(user.name); // John
330330
alert(User.prototype.name); // undefined
331331
```
332332

333-
<<<<<<< HEAD
334333
من الناحية الفنية ، تتم معالجتها بعد أن يقوم المنشئ بعمله ، ويمكننا استخدامه بالنسبة لهم التعبيرات المعقدة واستدعاءات الوظائف:
335-
=======
336-
We can also assign values using more complex expressions and function calls:
337-
>>>>>>> 445bda39806050acd96f87166a7c97533a0c67e9
338334

339335
```js run
340336
class User {
@@ -347,14 +343,9 @@ let user = new User();
347343
alert(user.name); // John
348344
```
349345

350-
<<<<<<< HEAD
351346
### عمل طرق مرتبطة بحقول class
352347

353348
كما هو موضح في الفصل <info: bind> ، فإن وظائف JavaScript لها ديناميكية `this`. يعتمد ذلك على سياق المكالمة.
354-
=======
355-
356-
### Making bound methods with class fields
357-
>>>>>>> 445bda39806050acd96f87166a7c97533a0c67e9
358349

359350
لذلك إذا تم تمرير طريقة كائن واستدعاؤها في سياق آخر ، فلن يكون `هذا` مرجعاً إلى كائنه بعد الآن.
360351

@@ -383,38 +374,10 @@ setTimeout(button.click, 1000); // undefined
383374

384375
هناك طريقتان لإصلاحها ، كما هو موضح في الفصل <info: bind>:
385376

386-
<<<<<<< HEAD
387377
1. قم بتمرير دالة مجمعة ، مثل `setTimeout (() => button.click ()، 1000)`.
388378
2. ربط طريقة الاعتراض ، على سبيل المثال في المنشئ:
389379

390-
```js run
391-
class Button {
392-
constructor(value) {
393-
this.value = value;
394-
*!*
395-
this.click = this.click.bind(this);
396-
*/!*
397-
}
398-
399-
click() {
400-
alert(this.value);
401-
}
402-
}
403-
404-
let button = new Button("hello");
405-
406-
*!*
407-
setTimeout(button.click, 1000); // hello
408-
*/!*
409-
```
410-
411380
توفر حقول class بنية أكثر أناقة للحل الأخير:
412-
=======
413-
1. Pass a wrapper-function, such as `setTimeout(() => button.click(), 1000)`.
414-
2. Bind the method to object, e.g. in the constructor.
415-
416-
Class fields provide another, quite elegant syntax:
417-
>>>>>>> 445bda39806050acd96f87166a7c97533a0c67e9
418381

419382
```js run
420383
class Button {
@@ -433,15 +396,9 @@ let button = new Button("hello");
433396
setTimeout(button.click, 1000); // hello
434397
```
435398

436-
<<<<<<< HEAD
437399
ينشئ حقل الفئة `click = () => {...}` وظيفة مستقلة على كل كائن `Button` ، مع` this` مرتبطًا بالكائن. ثم يمكننا تمرير "button.click" في أي مكان ، وسيتم استدعاؤها باستخدام `this` الصحيح.
438400

439401
هذا مفيد بشكل خاص في بيئة المتصفح ، عندما نحتاج إلى إعداد طريقة كمستمع للأحداث.
440-
=======
441-
The class field `click = () => {...}` is created on a per-object basis, there's a separate function for each `Button` object, with `this` inside it referencing that object. We can pass `button.click` around anywhere, and the value of `this` will always be correct.
442-
443-
That's especially useful in browser environment, for event listeners.
444-
>>>>>>> 445bda39806050acd96f87166a7c97533a0c67e9
445402

446403
## ملخص
447404

0 commit comments

Comments
 (0)