Represent Everyday Things with Objects
Represent Everyday Things with Objects
What is an Object?
When we take a look at an item, we can come up with a few key characteristics that describe it. Take for instance, a dog. When we think of a dog, we might describe it using characteristics like its name, its body size, fur color, etc… While each individual characteristic doesn’t represent a dog, collectively we get a sense of what a dog is.
Now, let’s think about how we could represent a dog in code. We could write all the dog’s information in a string, but it would be hard to extract information afterward. We could even store all the information in an array, but then we would have to rely on the ordering to keep track of each characteristic. What if we wrote out the information like so:
let theBestDogEver = { name: 'Air Bud', bodySize: 'large', furColor: 'golden'};
Copy to clipboard
let theBestDogEver = { name: 'Air Bud', bodySize: 'large', furColor: 'golden'};
Then our “characteristics” are stored as a collection of key-value pairs, like the key ofnameis tied with the value'Air Bud'. What we have in the example above is aJavaScriptobject! Generally, these “characteristics” that are tracked with key-value pairs are known asproperties. These properties don’t follow any set order, rather these properties all exist inside the dog object and we can easily retrieve and manipulate the values by the key.
As you start learning more about objects, you’ll see how you’ve actually interacted with objects before and expand the possibilities of your programs!
'The Codecademy Team, composed of experienced educators and tech experts, is dedicated to making tech skills accessible to all. We empower learners worldwide with expert-reviewed content that develops and enhances the technical skills needed to advance and succeed in their careers.'
Complete Payment to Unlock Full Guide & Source Code
You are viewing the 30% preview. Join TopCourseAI Pro to unlock the remaining 70% of this article, unblur all code snippets, and gain full access to all 412 technical projects and guides.
Ready to access the complete step-by-step tutorial?
Gain full unhindered access to all 412 technical projects and guides, unblur all source code snippets, and download runnable scripts.
Related Blueprints & Guides
View all 166 →Accessibility on the Platform
Codecademy is committed to providing a high-quality learning experience for all learners. That includes accommodating different usage forms such as auditory, motor, or visual restrictions, limited hardware, or other acce...
Web developmentAffordances, Signifiers, and Clickability
For users on the web, the mouse click is perhaps the most fundamental human-computer interaction. The webbecamethe web partially through the power ofhypertext, or text in one document that links to other documents or res...
Web developmentAuthentication and OAuth
Authenticationis the process used by applications to determine and confirm identities of users. It ensures that the correct content is shown to users. More importantly, it ensures that incorrect content is secured and u...
Ready to build production-grade AI systems?
Enjoyed this guide? Continue exploring our library of 166+ production blueprints, multi-agent swarms, and autonomous agent systems with 100% unblurred, executable source code.