1

I have an object like below:

var _names = { 
    '[email protected]' : { 
        '[email protected]' : {
            channel: '1234', 
            from: 'bob'
        }
    },
    '[email protected]' : { 
        '[email protected]' : {
            channel: '53345',
            from: 'dan'
        }
    }
};

How could i add the following to [email protected]:

        '[email protected]' : {
            channel: '23233', 
            from: 'judy'
        }

Any ideas?

1
  • Couldn't you make it more localized? Commented Mar 20, 2013 at 18:44

2 Answers 2

6

You can add it using the square bracket notation. Since your key names are not valid JavaScript variable names, you cannot use the dot notation.

_names['[email protected]']['[email protected]'] = {
    channel: '23233', 
    from: 'judy'
}
Sign up to request clarification or add additional context in comments.

Comments

0

This should work:

_names['[email protected]']['[email protected]'] = {
    channel: '23233', 
    from: 'judy'
};

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.