File tree Expand file tree Collapse file tree 5 files changed +78
-77
lines changed
1-js/08-prototypes/03-native-prototypes
2-defer-to-prototype-extended Expand file tree Collapse file tree 5 files changed +78
-77
lines changed Original file line number Diff line number Diff line change @@ -9,5 +9,5 @@ function f() {
9
9
alert (" Hello!" );
10
10
}
11
11
12
- f .defer (1000 ); // shows "Hello!" after 1 sec
12
+ f .defer (1000 ); // را نشان میدهد "Hello!" بعد از 1 ثانیه
13
13
```
Original file line number Diff line number Diff line change @@ -2,16 +2,16 @@ importance: 5
2
2
3
3
---
4
4
5
- # Add method "f.defer(ms)" to functions
5
+ # متد "f.defer(ms)" را به تابعها اضافه کنید
6
6
7
- Add to the prototype of all functions the method ` defer(ms) ` , that runs the function after ` ms ` milliseconds .
7
+ متد ` defer(ms) ` را به پروتوتایپ تمام تابعها اضافه کنید که تابع را بعد از ` ms ` میلیثانیه اجرا میکند .
8
8
9
- After you do it, such code should work :
9
+ بعد از اینکه آن را انجام دادید، چنین کدی باید کار کند :
10
10
11
11
``` js
12
12
function f () {
13
13
alert (" Hello!" );
14
14
}
15
15
16
- f .defer (1000 ); // shows "Hello!" after 1 second
16
+ f .defer (1000 ); // را نشان میدهد "Hello!" بعد از 1 ثانیه
17
17
```
Original file line number Diff line number Diff line change @@ -8,17 +8,17 @@ Function.prototype.defer = function(ms) {
8
8
}
9
9
};
10
10
11
- // check it
11
+ // آن را بررسی کنید
12
12
function f (a , b ) {
13
13
alert ( a + b );
14
14
}
15
15
16
- f .defer (1000 )(1 , 2 ); // shows 3 after 1 sec
16
+ f .defer (1000 )(1 , 2 ); // بعد از 1 ثانیه 3 را نمایش میدهد
17
17
```
18
18
19
- Please note: we use ` this ` in ` f.apply ` to make our decoration work for object methods .
19
+ لطفا توجه کنید: ما در ` f.apply ` از ` this ` استفاده کردیم تا کاری کنیم که دکور کردن برای متدهای شیء هم کار کند .
20
20
21
- So if the wrapper function is called as an object method, then ` this ` is passed to the original method ` f ` .
21
+ پس اگر تابع دربرگیرنده به عنوان متد شیء فراخوانی شود، سپس ` this ` به متد اصلی ` f ` پاس داده میشود .
22
22
23
23
``` js run
24
24
Function .prototype .defer = function (ms ) {
Original file line number Diff line number Diff line change @@ -2,18 +2,18 @@ importance: 4
2
2
3
3
---
4
4
5
- # Add the decorating "defer()" to functions
5
+ # دکوراتور "defer()" را به تابعها اضافه کنید
6
6
7
- Add to the prototype of all functions the method ` defer(ms) ` , that returns a wrapper, delaying the call by ` ms ` milliseconds .
7
+ متد ` defer(ms) ` را به پروتوتایپ تمام تابعها اضافه کنید که یک دربرگیرنده را برمیگرداند و فراخوانی را به اندازه ` ms ` میلیثانیه به تاخیر میاندازد .
8
8
9
- Here's an example of how it should work :
9
+ این کد نمونهای چگونگی کار کردن آن است :
10
10
11
11
``` js
12
12
function f (a , b ) {
13
13
alert ( a + b );
14
14
}
15
15
16
- f .defer (1000 )(1 , 2 ); // shows 3 after 1 second
16
+ f .defer (1000 )(1 , 2 ); // بعد از 1 ثانیه 3 را نمایش میدهد
17
17
```
18
18
19
- Please note that the arguments should be passed to the original function .
19
+ لطفا در نظر داشته باشید که آرگومانها باید به تابع اصلی پاس داده شوند .
You can’t perform that action at this time.
0 commit comments