symbols: "map immutable strings to internal values" - kinda constant-like. cannot concatenate
-symbols are immutable, will refer to the same object and same place in memory
-every time a string is written, it creates a new object with new place in memory (even if identical to something existing)
-string may also hurt program's memory if string objects are repeatedly created and destroyed (when same object could have been reused in their place
-mutable objects can cause bugs that are difficult to detect
IF TEXTUAL CONTENT OF OBJECT IS IMPORTANT, USE STRING
IF IDENTITY OF OBJECT IS IMPORTANT, USE SYMBOL
Top comments (0)