Explica este código JavaScript
const sayHi = () => {
return (() =>"Hi Javascript!")();
}
console.log(typeof sayHi());
- A.
number
- B.
object
- C.
string
- D.
TypeError
Respuesta en el primer comentario.
For further actions, you may consider blocking this person and/or reporting abuse
Sam Mortinger -
Vincent Dizon -
jeetvora331 -
Nick Ciolpan -
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:
C.
string
La función
sayHi
regresa una otra función de tipo flecha, dicha función es anónima y solo devuelve la cadenaHi JavaScript
, el detalle acá es que esta función anónima una vez regresada es inmediatamente llamada.Entonces
sayHi
será igual a la cadenaHi Javascript
y en conclusión sutypeof
igual astring
.Podriamos ver también este ejemplo si extraemos la función anónima y escribimos en una función auxiliar por aparte, de la siguente manera: