Explica este código JavaScript
const numeros = [1,2,3,4,5];
numeros.length = 0;
console.log(numeros); // ?
A. 1
B. 0
C. []
D. [1]
Respuesta en el primer comentario.
For further actions, you may consider blocking this person and/or reporting abuse
Joy Winter -
SilvenLEAF -
Matek -
Kaike Castro -
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 (3)
Respuesta:
C.
[]
El método
lenght
es un getter y un setter al mismo tiempo, esto quiere decir que podemos obtener valores y podemos establecer los mismos dependiendo a lo que se necesite.En este caso usar
length
y setterlo a0
es una buena manera de borrar todos los elementos de un arreglo.Obrigado pela explicação não sabia disso.
Gracias a ti por leer mi post estimado.