Paracetamol.js💊| #110: Explica este código JavaScript

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 …


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


Print Share Comment Cite Upload Translate Updates
APA

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/

MLA
" » Paracetamol.js💊| #110: Explica este código JavaScript." Cristian Fernando | Sciencx - Wednesday April 27, 2022, https://www.scien.cx/2022/04/27/paracetamol-js%f0%9f%92%8a-110-explica-este-codigo-javascript/
HARVARD
Cristian Fernando | Sciencx Wednesday April 27, 2022 » Paracetamol.js💊| #110: Explica este código JavaScript., viewed ,<https://www.scien.cx/2022/04/27/paracetamol-js%f0%9f%92%8a-110-explica-este-codigo-javascript/>
VANCOUVER
Cristian Fernando | Sciencx - » Paracetamol.js💊| #110: Explica este código JavaScript. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/04/27/paracetamol-js%f0%9f%92%8a-110-explica-este-codigo-javascript/
CHICAGO
" » Paracetamol.js💊| #110: Explica este código JavaScript." Cristian Fernando | Sciencx - Accessed . https://www.scien.cx/2022/04/27/paracetamol-js%f0%9f%92%8a-110-explica-este-codigo-javascript/
IEEE
" » Paracetamol.js💊| #110: Explica este código JavaScript." Cristian Fernando | Sciencx [Online]. Available: https://www.scien.cx/2022/04/27/paracetamol-js%f0%9f%92%8a-110-explica-este-codigo-javascript/. [Accessed: ]
rf:citation
» Paracetamol.js💊| #110: Explica este código JavaScript | Cristian Fernando | Sciencx | 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.

You must be logged in to translate posts. Please log in or register.