Skip to content

Commit 3896f10

Browse files
committed
More examples translated
1 parent 3ca9d23 commit 3896f10

File tree

5 files changed

+29
-31
lines changed

5 files changed

+29
-31
lines changed

1-js/04-object-basics/04-object-methods/4-object-property-this/solution.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
**Answer: an error.**
1+
**Răspuns: o eroare.**
22

3-
Try it:
3+
Încercați:
44
```js run
55
function makeUser() {
66
return {
@@ -11,18 +11,18 @@ function makeUser() {
1111

1212
let user = makeUser();
1313

14-
alert( user.ref.name ); // Error: Cannot read property 'name' of undefined
14+
alert( user.ref.name ); // Eroare: Cannot read property 'name' of undefined
1515
```
1616

17-
That's because rules that set `this` do not look at object definition. Only the moment of call matters.
17+
Acest lucru se datorează faptului că regulile care setează `this` nu se uita la definirea obiectului. Doar momentul apelului contează .
1818

19-
Here the value of `this` inside `makeUser()` is `undefined`, because it is called as a function, not as a method with "dot" syntax.
19+
Aici valoarea variabilei `this` din interiorul funcției `makeUser()` este `undefined`, deoarece este apelată ca funcție, nu ca o metodă cu sintaxa "punct".
2020

21-
The value of `this` is one for the whole function, code blocks and object literals do not affect it.
21+
Valoarea variabilei `this` este unică pentru întreaga funcția, blocurile de cod și obiectele literale nu o afectează.
2222

23-
So `ref: this` actually takes current `this` of the function.
23+
În concluzie `ref: this` preia de fapt variabila curentă `this` a funcției.
2424

25-
Here's the opposite case:
25+
Iată cazul opus:
2626

2727
```js run
2828
function makeUser() {
@@ -41,4 +41,4 @@ let user = makeUser();
4141
alert( user.ref().name ); // John
4242
```
4343

44-
Now it works, because `user.ref()` is a method. And the value of `this` is set to the object before dot `.`.
44+
Acum funcționează, pentru că `user.ref()` este o metodă. Iar valoarea variabilei `this` este setată la obiectul dinaintea punctului `.`.

1-js/04-object-basics/04-object-methods/4-object-property-this/task.md

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

33
---
44

5-
# Using "this" in object literal
5+
# Folosirea "this" în obiect literal
66

7-
Here the function `makeUser` returns an object.
7+
Aici funcția `makeUser` returnează un obiect.
88

9-
What is the result of accessing its `ref`? Why?
9+
Care este rezultatul accesării proprietății `ref`? De ce?
1010

1111
```js
1212
function makeUser() {
@@ -18,6 +18,5 @@ function makeUser() {
1818

1919
let user = makeUser();
2020

21-
alert( user.ref.name ); // What's the result?
21+
alert( user.ref.name ); // Care este rezultatul?
2222
```
23-

1-js/04-object-basics/04-object-methods/7-calculator/task.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@ importance: 5
22

33
---
44

5-
# Create a calculator
5+
# Creați un calculator
66

7-
Create an object `calculator` with three methods:
7+
Creați un obiect `calculator` cu trei metode:
88

9-
- `read()` prompts for two values and saves them as object properties.
10-
- `sum()` returns the sum of saved values.
11-
- `mul()` multiplies saved values and returns the result.
9+
- `read()` solicită două valori și le salvează ca proprietăți ale obiectului.
10+
- `sum()` returnează suma valorilor salvate.
11+
- `mul()` multiplică valorile salvate și returnează rezultatul.
1212

1313
```js
1414
let calculator = {
15-
// ... your code ...
15+
// ... codul vostru ...
1616
};
1717

1818
calculator.read();
@@ -21,4 +21,3 @@ alert( calculator.mul() );
2121
```
2222

2323
[demo]
24-

1-js/04-object-basics/04-object-methods/8-chain-calls/solution.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
The solution is to return the object itself from every call.
1+
Soluția este de a returna obiectul însuși la fiecare apelare.
22

33
```js run demo
44
let ladder = {
@@ -26,7 +26,7 @@ let ladder = {
2626
ladder.up().up().down().up().down().showStep(); // 1
2727
```
2828

29-
We also can write a single call per line. For long chains it's more readable:
29+
De asemenea, putem scrie câte o apelare pe linie. Pentru lanțurile lungi este mai lizibil:
3030

3131
```js
3232
ladder

1-js/04-object-basics/04-object-methods/8-chain-calls/task.md

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

33
---
44

5-
# Chaining
5+
# Înlănțuirea
66

7-
There's a `ladder` object that allows to go up and down:
7+
Există un obiect `ladder` (scară) care permite urcarea și coborârea:
88

99
```js
1010
let ladder = {
1111
step: 0,
12-
up() {
12+
up() {
1313
this.step++;
1414
},
15-
down() {
15+
down() {
1616
this.step--;
1717
},
18-
showStep: function() { // shows the current step
18+
showStep: function() { // arată pasul curent
1919
alert( this.step );
2020
}
2121
};
2222
```
2323

24-
Now, if we need to make several calls in sequence, can do it like this:
24+
În acest moment, dacă avem nevoie să facem mai multe apelări în ordine, le putem face astfel:
2525

2626
```js
2727
ladder.up();
@@ -30,10 +30,10 @@ ladder.down();
3030
ladder.showStep(); // 1
3131
```
3232

33-
Modify the code of `up`, `down` and `showStep` to make the calls chainable, like this:
33+
Modificați codul pentru `up`, `down` și `showStep` pentru a face apelările înlănțuibile, astfel:
3434

3535
```js
3636
ladder.up().up().down().showStep(); // 1
3737
```
3838

39-
Such approach is widely used across JavaScript libraries.
39+
Asemenea abordare este utilizată pe scară largă în librăriile JavaScript.

0 commit comments

Comments
 (0)