0

I pass a string through "objName".

I want this to to be stored in the line: facebookData.objName

For example:

if I invoke the function like, fetchData(0, response, "friendsCount"), the object should be like: facebookData.friendsCount = dLen;

Note: facebookData is a global object.

             function fetchData(dLen, response, objName){

                if(response.paging){

                    if(!response.paging.next){

                        facebookData.objName = dLen; //Problem is here
                        return dLen;
                    }
                    else{
                        -------------------
                       fetchData(dLen, response, objName);
                    }
                }
1
  • 1
    You should use bracket notation: facebookData[objName] = dLen; Commented Jul 17, 2013 at 5:22

1 Answer 1

3

Use brackets:

facebookData[objName] = dLen;
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.