DELAPARRA
Index
Color
NL
Category: Programming paradigms

Symbol

Explained by Updated

What is Symbol?

Symbol: An identifier treated as a value in its own right, not evaluated — e.g. 'foo in Lisp is the symbol foo, not a call to it. A symbol is an identifier treated as a value itself. In Lisp, 'customer is the symbol named customer, not a lookup of a variable called customer. Ruby has symbols like :customer, and JavaScript has a Symbol type.

Definition source Coders Lingo, CC BY 4.0

Frequently asked questions about Symbol

How is Symbol used in practice?

Symbols are useful as names and keys. They are cheap to compare, because two symbols with the same name are the same object, and they make clear that a value is a label rather than text to display.

What should you keep in mind with Symbol?

In JavaScript, Symbol() creates unique keys that cannot clash with other properties, which libraries use to attach hidden metadata to objects. Well-known symbols like Symbol.iterator let your own objects work with for...of. In PHP, the closest equivalents are enums and class constants, which give named, comparable values instead of loose strings.

At a glance

CategoryProgramming paradigms
Explained by
Updated

More Programming paradigms terms

All terms starting with S

Skills

Download all skills (zip)

Manuals

Related services

Need any help?

Stuck on one of these in your own project? Tell me what you are working on and I will tell you how I would approach it.