Wednesday, October 3, 2012

Concat/append json

This was a tough nut to crack. I scoured the internet for about an hour. This solution owes a thanks to Nikhil Dvivedi. The Javascript master.

var langObj = {
 a : one,
 b: two
}

var langObj2 = {
 c:three,
 d:four
}

for( var key in langObj2 ) {
 langObj[ key ] = langObj2[ key ];
}

langObj2 will be:
{
 a:one,
 b:two,
 c:three,
 d:four
}

No comments:

Post a Comment