Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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.

Thanks!

1 Answer

Kevin Gates
Kevin Gates
15,053 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,743 Points

That's helpful, thanks!

Kevin Gates
Kevin Gates
15,053 Points

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