1

I have the following code in the Javascript

var data = {
                    itemFromIndex :  status.next,
                    requestId :      status.requestId,
                    loggedInAdminId: self.loggedInAdminId,
                    fetchedAllTerms : status.fetchedAllTerms
       }

How can i add an another item later into the data object? like i want to add

dbTermsFetchToIndex : status.dbTermsFetchToIndex

into data.

1 Answer 1

8

First, that's not an array, it's an object literal. Second, yes you can:

data.dbTermsFetchToIndex = status.dbTermsFetchToIndex;

Will have the same effect as if you declared it in your object literal in the first place.

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

2 Comments

also i tried data['dbTermsFetchToIndex'] = status.dbTermsFetchToIndex; Is this an other alternate, correct me if am wrong.
@SangramAnand Yes - that is an alternative.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.