masSdev masSdev - 2 months ago 6
Javascript Question

Push key value pair to map object javascript

I have the following object

{
"timetable": {
"MONDAY": {
"start-end0": {},
"start-end1": {},
"start-end2": {},
"start-end3": {},
"start-end4": {}
}
}


i need to add
"start-end5"
to
MONDAY
. I tried to use dot operator to monday like
timetable.monday.start-end5={}
it says monday undefined

Answer

One more completely viable (and very readable) syntax I'd like to add, just for fun:

time["timetable"]["MONDAY"]["start-end5"] = {};