Skip to content

Instantly share code, notes, and snippets.

@teffcode
Created June 24, 2020 06:25
Show Gist options
  • Save teffcode/ab383734fb4976523bd719012e2a2781 to your computer and use it in GitHub Desktop.
Save teffcode/ab383734fb4976523bd719012e2a2781 to your computer and use it in GitHub Desktop.

馃憢馃徏 Welcome 馃憢馃徏

Quiz banner

Instagram | Twitter | LinkedIn


Choose your language 馃憛



English version 馃殌


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



Spanish version 馃殌


驴 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



@hugok2k
Copy link

hugok2k commented Jun 24, 2020

Hola Teff! gracias por los quiz 馃槉, sigo aprendiendo aun y esto ayuda much铆simo. Un peque帽o detalle, vienes arrastrando un inconveniente con los links internos english y spanish version en los 3 煤ltimos quiz, solo es un guion 馃檶

@teffcode
Copy link
Author

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 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment