0

My Arrays are:

var FirstArr=[
              {
                "id":"123",
                "aboutUS":"Demo About Us"
              },
              {
                "id":"234",
                 "tutorial":"Demo Tutorial"
              }
             ];
var SecondArr=[
               {
            data:"aboutUS"
               },
           {
        "data":"toturial"
           }
              ];

I am not getting the value in temp,sTemp as a property is not working and showing undefined.

var sTemp=SecondArr[0].data;

var temp=FirstArr[0].sTemp;

Please Suggest me the solution....

0

1 Answer 1

1

The error is in your notation you should use [] with a variable property name so

var temp=FirstArr[0][sTemp];

See this plnkr: http://embed.plnkr.co/QY9aWDgxll3PcaO6ZgjN/preview

It console logs the temp value.

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.