Explica este código JavaScript
console.log(`${(x => x)('I love')} to program`)
- A:
I love to program
- B:
undefined to program
- C:
${(x => x)('I love') to program
- D:
TypeError
Respuesta en el primer comentario.
For further actions, you may consider blocking this person and/or reporting abuse
jdowns525 -
Ethan -
Taylor Hunt -
Eduard Krivanek -
Once suspended, duxtech will not be able to comment or publish posts until their suspension is removed.
Once unsuspended, duxtech will be able to comment and publish posts again.
Once unpublished, all posts by duxtech will become hidden and only accessible to themselves.
If duxtech is not suspended, they can still re-publish their posts from their dashboard.
Once unpublished, this post will become invisible to the public and only accessible to Cristian Fernando .
They can still re-publish the post if they are not suspended.
Thanks for keeping DEV Community safe. Here is what you can do to flag duxtech:
Unflagging duxtech will restore default visibility to their posts.
Top comments (1)
Respuesta
A:
I love to program
Al usar los backtiks de ES6, las expresiones se evaluan primero.
En este caso la expresión completa es:
Donde:
(x => x)
es una función anónima de tipo flecha, que recibe un parámetrox
y con un return implícito lo devuelve.('I love')
es la llamada a la función anónima, acá pasamos como argumento a la función la cadenaI love
.Entonces, la función es llamada y regresa únicamente el parámetro que se le pasa. Por ello la respuesta es
I love to program
.