Instagram | Twitter | LinkedIn
What is the output of the following code ?
A. undefined
B. Reference Error
C. 馃嵃
馃憖 Click here to see the correct answer and explanation
| Correct Answer | Explanation |
|---|---|
| A | The this value (internally) is not actually bound to the arrow function. Normal functions in JavaScript bind their own this value, however the this value used in arrow functions is actually fetched lexically from the scope it sits inside (where the object was defined). In this case, this refers to window object, so, window.cake = undefined. |
Explanation based on 馃憠馃徏 ES6 arrow functions, syntax and lexical scoping & Methods in ES6 objects: using arrow functions
驴 Qu茅 imprime el siguiente c贸digo ?
A. undefined
B. Reference Error
C. 馃嵃
馃憖 Haz click aqu铆 para ver la respuesta correcta y su explicaci贸n
| Respuesta correcta | Explicaci贸n |
|---|---|
| A | El valor de this no est谩 realmente vinculado a la funci贸n flecha (o arrow function en ingl茅s). Las funciones normales en JavaScript vinculan su propio valor this, sin embargo, el valor de this utilizado en las funciones flecha en realidad se obtiene l茅xicamente del 谩mbito en el que se encuentra (en donde se defini贸 el objeto). En este caso, this se refiere al objeto window, por lo que, window.cake = undefined. |
Explicaci贸n basada en 馃憠馃徏 ES6 arrow functions, syntax and lexical scoping & Methods in ES6 objects: using arrow functions


Hola @hugok2k ! 馃槺 Muchas gracias !!! Creo que es porque cambi茅 la posici贸n del emoji y al link olvid茅 quitarle un gui贸n medio que separaba el emoji del texto 馃槄 En cuanto tenga un tiempito lo corrijo ! Nuevamente, mil graciasss !