Instagram | Twitter | LinkedIn
What is the output of the following code: A, B or C?
Click here to see the correct answer and explanation 👀
Correct Answer | Explanation |
---|---|
C | Since the spread operator "spreads" an array into different arguments, any functions that accepts multiple any number of arguments can benefit from use of the spread operator. |
Explanation based on 👉🏼 How to Use the Spread Operator (…) in JavaScript | Medium
Code:
const mothers = ['👩🏻', '👩🏻', '👩🏻', '👽']
const happyMonth = (m1, m2, m3) => {
console.log(`${m1}${m2}${m3}`)
}
happyMonth(...mothers)
¿Qué imprime el siguiente código: A, B o C?
Haz click aquí para ver la respuesta correcta y su explicación 👀
Respuesta correcta | Explicación |
---|---|
C | Dado que el Spread Operator "extiende" una matriz en diferentes argumentos, cualquier función que acepte varios argumentos puede beneficiarse del uso de este Spread Operator. |
Explicación basada en 👉🏼 How to Use the Spread Operator (…) in JavaScript | Medium
Código:
const mothers = ['👩🏻', '👩🏻', '👩🏻', '👽']
const happyMonth = (m1, m2, m3) => {
console.log(`${m1}${m2}${m3}`)
}
happyMonth(...mothers)