You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 1-js/04-object-basics/08-symbol/article.md
+3Lines changed: 3 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -44,6 +44,8 @@ alert(id1 == id2); // false
44
44
45
45
If you are familiar with Ruby or another language that also has some sort of "symbols" -- please don't be misguided. JavaScript symbols are different.
46
46
47
+
To summarize, symbols are "special unique values" with optional description. Let's see where we can use them.
48
+
47
49
````warn header="Symbols don't auto-convert to a string"
48
50
Most values in JavaScript support implicit conversion to a string. For instance, we can `alert` almost any value, and it will work. Symbols are special. They don't auto-convert.
49
51
@@ -80,6 +82,7 @@ alert(id.description); // id
80
82
81
83
## "Hidden" properties
82
84
85
+
83
86
Symbols allow us to create "hidden" properties of an object, that no other part of code can accidentally access or overwrite.
84
87
85
88
For instance, if we're working with `user` objects, that belong to a third-party code. We'd like to add identifiers to them.
0 commit comments