Skip to content

Instantly share code, notes, and snippets.

@teffcode
Created October 19, 2020 00:24
Show Gist options
  • Select an option

  • Save teffcode/b4fab214740204a2e5f6ff531b30c15c to your computer and use it in GitHub Desktop.

Select an option

Save teffcode/b4fab214740204a2e5f6ff531b30c15c 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 ?


Click here to see the correct answer and explanation 馃憖
Correct Answer Explanation
B With apply method, we can pass the this context as the first argument and we can also pass additional arguments, but we have to pass them in an array (description.apply(movie, ["thriller", "馃嵖"])).

Explanation based on 馃憠馃徏 Understanding This, Bind, Call, and Apply in JavaScript | DigitalOcean

Code:

const movie = {
  name: "The invitation 馃嵎"
}

function description(genre, emoji) {
  console.log(`${this.name} is a ${genre} movie ${emoji}.`)
}

description.apply(movie, "thriller", "馃嵖")


Spanish version 馃殌


驴Qu茅 imprime el siguiente c贸digo?


Haz click aqu铆 para ver la respuesta correcta y su explicaci贸n 馃憖
Respuesta correcta Explicaci贸n
B Con el m茅todo apply, podemos pasar el contexto this como primer argumento y tambi茅n, podemos pasar argumentos adicionales, pero, en un array (description.apply(movie, ["thriller", "馃嵖"])).

Explicaci贸n basada en 馃憠馃徏 Understanding This, Bind, Call, and Apply in JavaScript | DigitalOcean

C贸digo:

const movie = {
  name: "The invitation 馃嵎"
}

function description(genre, emoji) {
  console.log(`${this.name} is a ${genre} movie ${emoji}.`)
}

description.apply(movie, "thriller", "馃嵖")


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