-
Notifications
You must be signed in to change notification settings - Fork 231
Object methods, "this" #343
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
937e47f
6ea2d55
6f38e54
0893548
cec58a6
12bef1e
39d13f7
fc63d96
f0bfccc
a0a4875
41c48b0
3803ad0
1b97e0f
5b91491
c60d007
066f260
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,6 +1,6 @@ | ||||||
| **Answer: an error.** | ||||||
| **Respuesta: un error.** | ||||||
|
|
||||||
| Try it: | ||||||
| Pruébalo: | ||||||
| ```js run | ||||||
| function makeUser() { | ||||||
| return { | ||||||
|
|
@@ -11,29 +11,29 @@ function makeUser() { | |||||
|
|
||||||
| let user = makeUser(); | ||||||
|
|
||||||
| alert( user.ref.name ); // Error: Cannot read property 'name' of undefined | ||||||
| alert( user.ref.name ); // Error: No se puede leer la propiedad 'name' de undefined | ||||||
| ``` | ||||||
|
|
||||||
| That's because rules that set `this` do not look at object definition. Only the moment of call matters. | ||||||
| Esto es porque porque las reglas que establecen el `this` no buscan en la definición del objeto. Solamente importa el momento en que se llama. | ||||||
joaquinelio marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
|
|
||||||
| Here the value of `this` inside `makeUser()` is `undefined`, because it is called as a function, not as a method with "dot" syntax. | ||||||
| Aquí el valor de `this` dentro de `makeUser()` es `undefined`, porque es llamado como una función, no como un método con sintaxis de punto. | ||||||
|
|
||||||
| The value of `this` is one for the whole function, code blocks and object literals do not affect it. | ||||||
| El valor de `this` es uno para la función entera, bloques de código y objetos literales no lo afectan. | ||||||
joaquinelio marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| El valor de `this` es uno para la función entera, bloques de código y objetos literales no lo afectan. | |
| El valor de `this` es uno para la función entera. Bloques de código y objetos literales no lo afectan. |
Funciona bien así como dos oraciones independientes en el mismo párrafo y pienso que se entiende mejor. Si lo leo con la coma me voy de corrido y pienso que es "función entera, bloques de código y objetos literales" hasta que mi cerebro hace corto circuito al encontrarse con "no lo afectan".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@maksumi la coma es justamente de pausa en este caso. No se recomiendo usa punto para dar pausa o separar oraciones pequeñas.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
creo qu amerita un " ; " !!!
si está mal no me importa.
Creo que se lee bien en una oracion si lee con el ritmo adecuado,
tambien reo que se puede poner en dos oraciones aunque se corte un poquito
pero asi no hay duda:
El valor de this es uno para la función entera; bloques de código y objetos literales no lo afectan.
podria haber puesto
fun entera, ni bloquess ni lieterales...
fun entera (biques y leterales....)
muy feo.
Uh oh!
There was an error while loading. Please reload this page.