A “symbol” represents a unique identifier.
A value of this type can be created using Symbol():
Symbols allow us to create “hidden” properties of an object, that no other part of code can accidentally access or overwrite.
Symbols are skipped by for…in
Symbol is used when:
“Hidden” object properties. If we want to add a property into an object that “belongs” to another script or a library, we can create a symbol and use it as a property key. A symbolic property does not appear in for..in, so it won’t be accidentally processed together with other properties. Also it won’t be accessed directly, because another script does not have our symbol. So the property will be protected from accidental use or overwrite.
Смотрите видео symbol datatype in javascript | consfused when and where to use symbol? онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Quick Code Academy 22 Февраль 2022, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 6,408 раз и оно понравилось 133 людям.