Press "Enter" to skip to content

Combining javascript objects into one

This article shows how to combine two objects into a single object. One of the simplest ways to combine multiple js objects into single object.

Example below:

var a = {
test: false,
test2: false,
text:'sample text here'
var b = {
test2: true,
test3: false

Merging function

var merge = function( first, second ) {
for (key in second){
return first;

call the merge function