0

I have setup this js object:

 var tableTypes = {
        "stockRcmnd":{
            "name":"stockRcmnd",
            "columns": ['1','2', '3']
        }, 
        "stockChange":{
            "name":"stockChange",
            "columns": ['4','5', '6']
        }
    };

now, I want to get the columns , dynamically:

property = "stockChange";

columns = tableTypes.{property}.columns;

property = "stockRcmnd";

columns = tableTypes.{property}.columns;

here is a jsfiddle;

any idea how to do it?

2 Answers 2

1

Object properties can also be accessed like this in JavaScript:

tableTypes[property].columns

Sign up to request clarification or add additional context in comments.

Comments

0

Just:

   tableTypes['stockRcmnd'].name

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.