Skip to content

Commit 5fcf3df

Browse files
committed
Translate "Using 'this' in object literal" and related content to Portuguese
1 parent 889dbfc commit 5fcf3df

2 files changed

Lines changed: 15 additions & 15 deletions

File tree

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
**Answer: an error.**
1+
**Resposta: um erro.**
22

3-
Try it:
3+
Experimente:
44
```js run
55
function makeUser() {
66
return {
@@ -14,26 +14,26 @@ let user = makeUser();
1414
alert( user.ref.name ); // Error: 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+
Isso é porque as regras que definem `this` não olham para a definição do objeto. Apenas o momento da chamada importa.
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+
Aqui o valor de `this` dentro de `makeUser()` é `undefined`, porque ela é chamada como uma função, não como um método com sintaxe de "ponto".
2020

21-
The value of `this` is one for the whole function, code blocks and object literals do not affect it.
21+
O valor de `this` é único para toda a função, blocos de código e literais de objeto não o afetam.
2222

23-
So `ref: this` actually takes current `this` of the function.
23+
Então `ref: this` na verdade obtém o `this` atual da função.
2424

25-
We can rewrite the function and return the same `this` with `undefined` value:
25+
Podemos reescrever a função e retornar o mesmo `this` com valor `undefined`:
2626

2727
```js run
2828
function makeUser(){
29-
return this; // this time there's no object literal
29+
return this; // desta vez não há literal de objeto
3030
}
3131

3232
alert( makeUser().name ); // Error: Cannot read property 'name' of undefined
3333
```
34-
As you can see the result of `alert( makeUser().name )` is the same as the result of `alert( user.ref.name )` from the previous example.
34+
Como você pode ver, o resultado de `alert( makeUser().name )` é o mesmo que o resultado de `alert( user.ref.name )` do exemplo anterior.
3535

36-
Here's the opposite case:
36+
Aqui está o caso oposto:
3737

3838
```js run
3939
function makeUser() {
@@ -52,4 +52,4 @@ let user = makeUser();
5252
alert( user.ref().name ); // John
5353
```
5454

55-
Now it works, because `user.ref()` is a method. And the value of `this` is set to the object before dot `.`.
55+
Agora funciona, porque `user.ref()` é um método. E o valor de `this` é definido como o objeto antes do ponto `.`.

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

Lines changed: 4 additions & 4 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+
# Usando "this" em literal de objeto
66

7-
Here the function `makeUser` returns an object.
7+
Aqui a função `makeUser` retorna um objeto.
88

9-
What is the result of accessing its `ref`? Why?
9+
Qual é o resultado de acessar seu `ref`? Por quê?
1010

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

1919
let user = makeUser();
2020

21-
alert( user.ref.name ); // What's the result?
21+
alert( user.ref.name ); // Qual é o resultado?
2222
```
2323

0 commit comments

Comments
 (0)