-1

I have seen the answer here:

access javascript object with space in key

But what would you do if

const parent = { "A B": 
  {
   "1 2": "Hello",
   "3": "World"
  }
}

How would you change "Hello" to Hi?

Community
  • 1
  • 1
Norfeldt
  • 6,180
  • 16
  • 85
  • 131
  • I would first get rid of the unnecessary and confusing use of `const`, then I would say `parent["A B"]["1 2"] = "Hi"` – mhodges Feb 07 '17 at 19:40

2 Answers2

4

Just the same, by multiple bracket notations in a row.

const parent = { "A B": 
  {
   "1 2": "Hello",
   "3": "World"
  }
}

parent["A B"]["1 2"] = 'Hi';

console.log(parent);
baao
  • 67,185
  • 15
  • 124
  • 181
1

Use brackets:

parent["A B"]["1 2"] = 'Hi';
Robsonsjre
  • 1,506
  • 9
  • 17