Instagram | Twitter | LinkedIn
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", "馃嵖")
驴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", "馃嵖")

