Attribute
PronunciationAT-rih-byoot
Definition
An attribute is a piece of data that belongs to an object, such as the name of a member. You read it with a dot, like member.name.
Where you hear it
In object-oriented code, Python and JavaScript tutorials, and errors such as AttributeError.
Examples
The member object has two attributes: a name and a number of shares.
The error says the object has no attribute called
total.The user object has an email attribute that the login form reads.
Common mistake
Confusing an attribute with a method. An attribute holds data; a method is a function you call with parentheses.
Don't confuse with
A property, which looks like an attribute but runs code when you read or write it.
Say it at work
- In a meeting or chat
Store it as an attribute set in the constructor.
- In an email or ticket
That attribute is missing on some objects, which is why it crashes.
Keep exploring
More in Programming Fundamentals