Explica este código JavaScript
console.log("hola".split("").reverse().join("")); // ?
A. ['h','o','l','a']
;
B. ['a','l','o','h']
C. "hola"
D. "aloh"
Resuesta el el primer ocmentario.
For further actions, you may consider blocking this person and/or reporting abuse
Denzel Kanyeki -
Noobiz Developer -
Steven Murawski -
C K Sanjay Babu -
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 (2)
Respuesta:
D.
"aloh"
Estos 3 métodos de cadenas se preguntan mucho en entrevistas.
Veamos paso por paso que sucede:
Aplicamos
split
:split
convierte una cadena en arreglo dependiendo del parámetro que se le pase, en este caso una cedena vacía:['h','o','l','a']
.Aplicamos
reverse
:reverse
es un método de arreglos, invierte todos los elementos del arreglo:['a','l','o','h']
.Aplicamos
join
:join
es un método de arreglos que convierte un arreglo en cadena nuevamente dependiendo del parámetro que se le pase, en este caso una cadena vacía:"aloh"
Be careful with
split
:Also, this is interesting: