Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript Object-Oriented JavaScript Getters and Setters Object Interaction

Uses for Object oriented programming with JavaScript

I've seen OOP JS used for JS game creation. What other ways would you use this?

As I go through this class it seems like its a way to dynamically collect the users data, almost like its a table.


1 Answer

Kevin Gates
Kevin Gates
14,860 Points

Here's an overview of it from Mozilla: https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/Object-oriented_JS

To further answer though, it's uses could be varied. You may have a Node + Express backend for your website, therefore you will need something to help process and manage your user data and interact with your database. This can be incredibly helpful.

However, this is just as helpful for front-end technologies. Let's say you have a membership website -- for instance, Dog Walkers of New York. Your site discusses events, group leaders, and more.

Therefore, when you are showing your membership data to a user, you will likely get information from the database: the neighborhood of the dog walker, the information on the owner, the information on the dogs in general. Perhaps you have different classes of dogs (small, medium, large) which is utilized for different events, then you have an events section. Every category you can think of can likely be represented by an object.

The neighborhood brought it from a database may be comprised of a title, location data, and potentially an array of Event Ids. Your owner can be an object of name, address, a sub-object contain name-value pairs for phone numbers, a sub-object of emergency contacts, a sub-object of veterinarian information, and an array of Dog Objects.

Your dog object could then have properties of name, breed, age, size, then possibly an array or object listing vaccinations on record.

This all can be data stored in a database that needs to be represented when you load a membership site for dog walkers. :)

matt thurmond
matt thurmond
8,499 Points

That's helpful, thanks!

Kevin Gates
Kevin Gates
14,860 Points

Hi Matt, will you upvote the response since you found it helpful? Thanks!