Merge Hashes

Javascript doesn’t have standard function to merger hashes. We can do it like below.

var hash1 = {'us': 'USD', 'jp': 'JPY'};
var hash2 = {'cn': 'CNY'};

for (var key in hash2) {
    hash1[key] = hash2[key];
}

 

Top