Skip to content

Commit e0e5386

Browse files
authored
Merge pull request #175 from mahdiHashemi14/master
Native prototypes
2 parents 8942ba5 + 2fcf4c6 commit e0e5386

File tree

5 files changed

+78
-77
lines changed

5 files changed

+78
-77
lines changed

1-js/08-prototypes/03-native-prototypes/1-defer-to-prototype/solution.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ function f() {
99
alert("Hello!");
1010
}
1111

12-
f.defer(1000); // shows "Hello!" after 1 sec
12+
f.defer(1000); // را نشان می‌دهد "Hello!" بعد از 1 ثانیه
1313
```

1-js/08-prototypes/03-native-prototypes/1-defer-to-prototype/task.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@ importance: 5
22

33
---
44

5-
# Add method "f.defer(ms)" to functions
5+
# متد "f.defer(ms)" را به تابع‌ها اضافه کنید
66

7-
Add to the prototype of all functions the method `defer(ms)`, that runs the function after `ms` milliseconds.
7+
متد `defer(ms)` را به پروتوتایپ تمام تابع‌ها اضافه کنید که تابع را بعد از `ms` میلی‌ثانیه اجرا می‌کند.
88

9-
After you do it, such code should work:
9+
بعد از اینکه آن را انجام دادید، چنین کدی باید کار کند:
1010

1111
```js
1212
function f() {
1313
alert("Hello!");
1414
}
1515

16-
f.defer(1000); // shows "Hello!" after 1 second
16+
f.defer(1000); // را نشان می‌دهد "Hello!" بعد از 1 ثانیه
1717
```

1-js/08-prototypes/03-native-prototypes/2-defer-to-prototype-extended/solution.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ Function.prototype.defer = function(ms) {
88
}
99
};
1010

11-
// check it
11+
// آن را بررسی کنید
1212
function f(a, b) {
1313
alert( a + b );
1414
}
1515

16-
f.defer(1000)(1, 2); // shows 3 after 1 sec
16+
f.defer(1000)(1, 2); // بعد از 1 ثانیه 3 را نمایش می‌دهد
1717
```
1818

19-
Please note: we use `this` in `f.apply` to make our decoration work for object methods.
19+
لطفا توجه کنید: ما در `f.apply` از `this` استفاده کردیم تا کاری کنیم که دکور کردن برای متدهای شیء هم کار کند.
2020

21-
So if the wrapper function is called as an object method, then `this` is passed to the original method `f`.
21+
پس اگر تابع دربرگیرنده به عنوان متد شیء فراخوانی شود، سپس `this` به متد اصلی `f` پاس داده می‌شود.
2222

2323
```js run
2424
Function.prototype.defer = function(ms) {

1-js/08-prototypes/03-native-prototypes/2-defer-to-prototype-extended/task.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@ importance: 4
22

33
---
44

5-
# Add the decorating "defer()" to functions
5+
# دکوراتور "defer()" را به تابع‌ها اضافه کنید
66

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` میلی‌ثانیه به تاخیر می‌اندازد.
88

9-
Here's an example of how it should work:
9+
این کد نمونه‌ای چگونگی کار کردن آن است:
1010

1111
```js
1212
function f(a, b) {
1313
alert( a + b );
1414
}
1515

16-
f.defer(1000)(1, 2); // shows 3 after 1 second
16+
f.defer(1000)(1, 2); // بعد از 1 ثانیه 3 را نمایش می‌دهد
1717
```
1818

19-
Please note that the arguments should be passed to the original function.
19+
لطفا در نظر داشته باشید که آرگومان‌ها باید به تابع اصلی پاس داده شوند.

0 commit comments

Comments
 (0)