Roy Hodge
Roy Hodge

Reputation: 1

How do I access the value of this JavaScript object?

What type of object is container?

var pname = "apples";
var extVal = "oranges";

var container = {};
container =
{
    presName: pname,
    presVal: pname
};

I want to compare the value of presVal (from inside container) to the value of extVal.

But I'm not sure how to access presVal to make this comparison.

Upvotes: 0

Views: 120

Answers (1)

Sina Fathieh
Sina Fathieh

Reputation: 1725

you can access properties of an object by using a dot, or putting it in [] so in your question :

if (container.parsVal===extVal) { ... } 

Upvotes: 4

Related Questions