0

I am trying to search an array with a variable, which seems to not work because it thinks the variable itself is a value.

var variable = "create";

var navViews = {
    "create" : [
        {
            "id"        : "1",
            "name"      : "Create",
            "urlext"    : "stylecreator"
        }
    ]
}
navViews.variable;

How do I reach "create" through a variable?

2
  • 5
    navViews[variable] navViews.variable; will check for "variable" inside navViews Commented Jul 2, 2015 at 9:09
  • Are you trying to search for a variable here, or just access it? Commented Jul 2, 2015 at 9:10

1 Answer 1

2

If you want to get create array, you can do this in this way:

navViews[variable]
Sign up to request clarification or add additional context in comments.

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.