Skip to content

Commit d620bfb

Browse files
authored
Change: Translate of the solution file in the check-syntax section
1 parent e7279d0 commit d620bfb

1 file changed

Lines changed: 12 additions & 9 deletions

File tree

  • 1-js/99-js-misc/04-reference-type/2-check-syntax
Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,32 @@
1-
**Error**!
1+
**خطا**!
22

3-
Try it:
3+
کد زیر را مدنظر داشته باشید:
44

55
```js run
66
let user = {
77
name: "John",
88
go: function() { alert(this.name) }
99
}
1010

11-
(user.go)() // error!
11+
(user.go)() // خطا دارد!
1212
```
1313

14-
The error message in most browsers does not give us much of a clue about what went wrong.
14+
پیام خطا در بیشتر مرورگر ها اطلاعاتی بابت اینکه چه اشتباهی رخ داده است نمیدهد.
1515

16-
**The error appears because a semicolon is missing after `user = {...}`.**
1716

18-
JavaScript does not auto-insert a semicolon before a bracket `(user.go)()`, so it reads the code like:
17+
** این خطا نشان داده میشود چون سمیکالن بعد از این دستور فراموش شده است `user = {...}`.**
18+
19+
20+
جاوااسکریپت به صورت پیش فرض سمیکالن را براکت قبل از دستور `(user.go)()` اضافه نمیکند. سپس کد به این صورت خوانده میشود:
1921

2022
```js no-beautify
2123
let user = { go:... }(user.go)()
2224
```
2325

24-
Then we can also see that such a joint expression is syntactically a call of the object `{ go: ... }` as a function with the argument `(user.go)`. And that also happens on the same line with `let user`, so the `user` object has not yet even been defined, hence the error.
26+
بنابراین جاوااسکریپت حدس میزند که ما درواقع آبجکت `{ go: ... }` را به عنوان یک فانکشن با آرگومان های `(user.go)` صدا زده ایم. و سپس چون به `let user` میرسیم آبجکت `user` به صورت تعریف نشده معرفی میشود و ما ارور را مشاهده میکنیم.
27+
2528

26-
If we insert the semicolon, all is fine:
29+
همه چیز خوب بنظر میرسد اگر سمیکالن را انتهای آبجکت اضافه کنیم:
2730

2831
```js run
2932
let user = {
@@ -34,4 +37,4 @@ let user = {
3437
(user.go)() // John
3538
```
3639

37-
Please note that parentheses around `(user.go)` do nothing here. Usually they setup the order of operations, but here the dot `.` works first anyway, so there's no effect. Only the semicolon thing matters.
40+
توجه داشته باشید که پرانتز اطراف `(user.go)` کاری انجام نمیدهد. معمولا در اکثر موقعیت ها اولویت عملگر هارا تغییر میدهند, اما در اینجا فقط عملگر نقطه `.` کار میکند. سپس مورد خاصی نیست و فعلا بحث سمیکالن مهم است.

0 commit comments

Comments
 (0)