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

Understanding Objects, Properties, and Methods in JavaScript...Comments?

I've been struggling wrapping my mind around objects, properties, and methods. I just completed the Objects tutorial in Treehouse's Intro to Programming. It helped a lot, but when I sit down and try to articulate what each one is, I struggle. Anyway, this is what I've come up with. I know my understanding is flawed right now. Anyone willing to help me understand where I'm mistaken or better ways of thinking of them?

Here is my understanding of Objects, Properties, and Methods from the Intro to Programming tutorial I just watched on Objects and from a JS tutorial I watched on YouTube. The guy has a whole series of them on JS topics and I've found them to be helpful to supplement the Treehouse tutorials and tracks.

Thank you so much for your help. -Eric

Objects, Properties, and Methods

Think of a car:

It's an OBJECT that is made up of PROPERTIES (color, name, etc).

Method: An action that we can perform with our object (start, drive, park).

In JS, every time you perform an action with the object, that's a METHOD.

My understanding:

Object: Anything I can affect or do something to. (ex. a varaiable). It has key value pairs or properties.

Properties: These belong to the object. They can be parts of it or describe it.

Method: An action placed on the object.

The period, or "full stop" (.) equals [" "] in object land.

2 Answers

You're pretty much spot on with your definitions.
Think of objects as anything you can put a noun to, and methods should be named with doing words or an action. Properties and Methods are the "components" that defines the object so that you can differentiate this object to another.

But because Javascript is usually not that strict, unless if you put it through jsLint or something like that, you shouldn't need to be too engrossed in differing these terms. Not that you should discount them, as it is a good idea to put your code into objects, but something for something small, they're just overkill.

John,

Thank you for taking the time to share your expertise and perspective. "Nouns", "Action Words", and "Components" helps me understand Objects, Methods, and Properties.

Thank you very much!! -Eric

Hi Eric, i think you're right about objects, is the same many tutorials teach. But in the real world, i'm still struggling with this concepts, because it's hard to think of in a simple way. Today you face more challenges than that, like method for developing software, patterns, and a whole lot of new technologies that are based on frameworks. I can't give you a tutorial but i have found a book that has help me a lot to understand this programming method, if you can afford to buy it you will not regret about it.

The Object Oriented Though Process

I hope it help's.

Juan,

Thank you for your excellent response. I followed up and read some reviews of The Object Oriented Thought Process. They are good and it sounds like a book that can help me!

Thank you again! -Eric