Can symbols in js be really reassigned? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 2

Can symbols in js be really reassigned?

In the code, let id = Symbol(); let user = { [id] : 12, }; user[id] = 14; alert(user[id]); Here, the value of symbol id is 14 on alert ie. Reassigned. But in specifications, they say symbols cannot be reassigned, so whats the concept here???

8th Jan 2022, 7:30 AM
Himansh
Himansh - avatar
1 Resposta
+ 4
Every symbol returned byĀ Symbol()Ā is unique, so every symbol has its own identity. https://www.freecodecamp.org/news/how-did-i-miss-javascript-symbols-c1f1c0e1874a/
8th Jan 2022, 4:17 PM
šŸ‘‘ ShadowCipher šŸ‡¦šŸ‡²
šŸ‘‘ ShadowCipher šŸ‡¦šŸ‡² - avatar