This content originally appeared on DEV Community and was authored by Cristian Fernando
Explica este código JavaScript
Dificultad: Básico
const set = new Set([1,2,1,5,9,5,0]);
for(let item of set){
console.log(item)
}
A. 1,2,1,5,9,5,0
B. 1 2 5 9 0
C. SyntaxisError
D. Ninguna de las anteriores
Respuesta en el primer comentario.
Respuesta:
B. 1 2 5 9 0
Para poder iterar sobre objetos Set
podemos usar un ciclo for...of
que recorrerá cada item
del nuestro Set
obviamente omitiendo los elementos repetidos.
This content originally appeared on DEV Community and was authored by Cristian Fernando
Cristian Fernando | Sciencx (2022-04-27T17:55:45+00:00) Paracetamol.js💊| #110: Explica este código JavaScript. Retrieved from https://www.scien.cx/2022/04/27/paracetamol-js%f0%9f%92%8a-110-explica-este-codigo-javascript/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.