jquery - Append object to child object in javascript -


i have following object:

var dpsets = {     "routes": [         {             "name": "first",             "values": [                 "info",                 "more info",                 "text"             ]         },         {             "name": "second",             "values": [                 "text again",                 "with info"              ]         }     ] } 

i have following object:

var currentset = {     "name": "new route",     "values": [         "latest one",         "latest two"     ] } 

i trying append currentset routes element of dpsets.

i have tried both dpsets.routes.push(currentset) , jquery's $.extend(dplocations.routes, currentroute) neither seemed require.

what's best way it?

originally didn't work:

dpsets.routes.push(currentset)

however, after trying again, worked fine.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -