Explica este código JavaScript
const arr = [];
console.log(Array.isArray(arr)); // ??
A. true
B. false
C. []
D. ReferenceError
Respuesta en el primer comentario.
For further actions, you may consider blocking this person and/or reporting abuse
Nijit Krishna Hazarika -
Nomadev -
Lorem Impsu -
shrey vijayvargiya -
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.
true
Una manera adecuada de comprobar que un arreglo es efectivamente un arreglo es usar el constructor
Array
con su métodoisArray
.Como
arr
es un arreglo (vacío pero arreglo al fin), entonces regresamostrue
.Como los arreglos no son un tipo de dato per se en JavaScript, la mejor manera de comprobar si un arreglo es un arreglo es de esta manera.
¿Te cuento un secreto? Esta pregunta es bastante frecuente en entrevistas laborales, pero shhh, no se lo digas a nadie 👀