-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
  • 8,272
  • 23
  • 96
  • 152
  • 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
  • 71,625
  • 17
  • 143
  • 203
1

Use brackets:

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