Skip to content

Commit 3ca9d23

Browse files
committed
Initial commit
1 parent 7faa7d7 commit 3ca9d23

File tree

4 files changed

+25
-27
lines changed

4 files changed

+25
-27
lines changed
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
1-
**Error**!
1+
**Eroare**!
22

3-
Try it:
3+
Incercați:
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)() // eroare!
1212
```
1313

14-
The error message in most browsers does not give understanding what went wrong.
14+
Din mesajul de eroare furnizat de majoritatea browserelor nu reiese ce a mers prost.
1515

16-
**The error appears because a semicolon is missing after `user = {...}`.**
16+
**Eroarea apare deoarece semicolonul ";" lipsește după `user = {...}`.**
1717

18-
JavaScript does not auto-insert a semicolon before a bracket `(user.go)()`, so it reads the code like:
18+
Limbajul JavaScript nu adaugă automat un semicolon înainte de paranteză `(user.go)()`, deci citește codul ca:
1919

2020
```js no-beautify
2121
let user = { go:... }(user.go)()
2222
```
2323

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.
24+
Apoi, putem vedea, de asemenea, că o stfel de expresie combinată este sintactic un apel al obiectului `{ go: ... }` ca funcție cu argumentul `(user.go)`. Și asta se întâmplă și pe aceeași linie cu `let user`, deci obiectul `user` nu a fost încă definit, de unde și eroarea.
2525

26-
If we insert the semicolon, all is fine:
26+
Dacă introducem un semicolon, totul este în regulă:
2727

2828
```js run
2929
let user = {
@@ -34,4 +34,4 @@ let user = {
3434
(user.go)() // John
3535
```
3636

37-
Please note that brackets 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.
37+
Rețineți că parantezele din jurul `(user.go)` nu fc nimic aici. De obicei setează ordinea operațiunilor, dar aici punctul `.` are oricum precedență, deci nu are niciun efect. Singura chestie care contează este semicolonul.

1-js/04-object-basics/04-object-methods/2-check-syntax/task.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ importance: 2
22

33
---
44

5-
# Syntax check
5+
# Verificare de sintaxă
66

7-
What is the result of this code?
7+
Care este rezultatul următorului cod?
88

99

1010
```js no-beautify
@@ -16,4 +16,4 @@ let user = {
1616
(user.go)()
1717
```
1818

19-
P.S. There's a pitfall :)
19+
P.S. Există o capcană :)
Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11

2-
Here's the explanations.
2+
Iată explicațiile.
33

4-
1. That's a regular object method call.
4+
1. Aceasta este o apelare normală a metodei obiectului.
55

6-
2. The same, brackets do not change the order of operations here, the dot is first anyway.
6+
2. Similar, aici, parantezele nu schimbă ordinea operațiunilor, punctul este oricum primul.
77

8-
3. Here we have a more complex call `(expression).method()`. The call works as if it were split into two lines:
8+
3. Aici avem un apel mai complex `(expression).method()`. Apelul funcționează ca și cum ar fi împărțit în două linii:
99

1010
```js no-beautify
11-
f = obj.go; // calculate the expression
12-
f(); // call what we have
11+
f = obj.go; // calculează expresia
12+
f(); // apelează ce avem
1313
```
1414

15-
Here `f()` is executed as a function, without `this`.
15+
Aici `f()` este executat ca funcție, fără `this`.
1616

17-
4. The similar thing as `(3)`, to the left of the dot `.` we have an expression.
17+
4. Chestia similară cu `(3)`, la stânga punctului `.` avem o expresie.
1818

19-
To explain the behavior of `(3)` and `(4)` we need to recall that property accessors (dot or square brackets) return a value of the Reference Type.
20-
21-
Any operation on it except a method call (like assignment `=` or `||`) turns it into an ordinary value, which does not carry the information allowing to set `this`.
19+
Pentru a explica comportamentul apelurilor `(3)` și `(4)` trebuie să ne reamintim că accesorii de proprietăți (punct sau paranteze pătrate) returnează o valoare de Tip Referință.
2220

21+
Orice operațiune pe aceasta, cu excepția unui apel de metodă (precum alocarea `=` sau `||`) o transformă într-o valoare obișnuită, care nu poartă informațiile ce permit setarea variabilei `this`.

1-js/04-object-basics/04-object-methods/3-why-this/task.md

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

33
---
44

5-
# Explain the value of "this"
5+
# Explicați valoarea variabilei "this"
66

7-
In the code below we intend to call `user.go()` method 4 times in a row.
7+
În codul următor intenționăm să apelăm metoda `user.go()` de 4 ori la rând.
88

9-
But calls `(1)` and `(2)` works differently from `(3)` and `(4)`. Why?
9+
Însă apelurile `(1)` și `(2)` funcționează diferit de `(3)` și `(4)`. De ce?
1010

1111
```js run no-beautify
1212
let obj, method;
@@ -23,4 +23,3 @@ obj.go(); // (1) [object Object]
2323

2424
(obj.go || obj.stop)(); // (4) undefined
2525
```
26-

0 commit comments

Comments
 (0)