Link to home
Start Free TrialLog in
Avatar of Bruce Gust
Bruce GustFlag for United States of America

asked on

Is my terminology correct here?

Here's my code:

let cart = {products: [], totalPrice: 0}

Open in new window


If I were explaining this to someone, I would say that "cart" is an object with two properties: an empty array called "products" and a "totalPrice" property with a value of 0.

Is that correct?
SOLUTION
Avatar of Phil Phillips
Phil Phillips
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Bruce Gust

ASKER

Phil, this might be going a little too detailed / into the weeds, but...

The reason it's an "object" is because, whether you're talking about PHP, Node or JQuery, an object is going to be the digital mechanism by which you're invoking elements of a Class. That Class is a blueprint, the object is the "thing" that results from putting that Class into action.

And...

That object is an instance of the corresponding Class.

And as far as my referring to the empty array and the "totalProperties" elements as properties...

They're not arguments. Arguments are what you pass into a function or method.

The reason I was hesitating when it came to referring to them as properties is because I know that term to be used when you're describing entities that you want to use over and over again in a Class (PHP). You'll have a constructor and then you'll use the "this" operator (I've seen it referred to as a "pseudo variable" in PHP) to assign values to those properties.

I know I'm getting into some detail that may not be necessary, but I want to be able to teach this material to others and I want to know what I'm talking about.

Thanks!
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you gentlemen!