How to access the value of this javascript object?

What type of container object?

 var pname = "apples"; var extVal = "oranges"; var container = {}; container = { presName: pname, presVal: pname }; 

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

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

0
source share
1 answer

you can access the properties of an object with a dot or put it in [], so in your question:

 if (container.parsVal===extVal) { ... } 
+4
source

Source: https://habr.com/ru/post/1338130/


All Articles