-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #423 from danilolmc/update-reference-type
Reference Type
- Loading branch information
Showing
5 changed files
with
70 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,20 @@ | ||
Aqui estão as explicações. | ||
|
||
Here's the explanations. | ||
1. Isso é uma chamada de método de objeto regular. | ||
|
||
1. That's a regular object method call. | ||
2. O mesmo, parênteses não alteram a ordem das operações aqui, o ponto é executado primeiro de qualquer maneira. | ||
|
||
2. The same, parentheses do not change the order of operations here, the dot is first anyway. | ||
|
||
3. Here we have a more complex call `(expression)()`. The call works as if it were split into two lines: | ||
3. Aqui temos uma chamada mais complexa (expressão)(). A chamada funciona como se estivesse dividida em duas linhas: | ||
|
||
```js no-beautify | ||
f = obj.go; // calculate the expression | ||
f(); // call what we have | ||
f = obj.go; // calcula a expressão | ||
f(); // chama o que temos | ||
``` | ||
|
||
Here `f()` is executed as a function, without `this`. | ||
|
||
4. The similar thing as `(3)`, to the left of the parentheses `()` we have an expression. | ||
Aqui, f() é executado como uma função, sem this. | ||
|
||
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. | ||
4. A coisa semelhante ao `(3)`, à esquerda dos parênteses `()` temos uma expressão. | ||
|
||
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`. | ||
Para explicar o comportamento de `(3)` e `(4)`, precisamos lembrar que os acessadores de propriedade (ponto ou colchetes) retornam um valor do Tipo de Referência. | ||
|
||
Qualquer operação nele, exceto uma chamada de método (como a atribuição `=` ou `||`), o transforma em um valor comum, que não carrega a informação permitindo configurar `this`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters