0

While executing the below snippet, I'm getting an error stating "Uncaught TypeError: undefined is not a function" error.

Can someone shed some light here?.

var a1={'Param1':'122','Param2':'123','Param3':'124','Param4':'125'};
var b={'Param1':'22','Param2':'23','Param3':'24','Param4':'25'};
var c=a1.concat(b);

Thanks, Dave

David R
  • 14,711
  • 7
  • 54
  • 72

2 Answers2

0

Object.prototype.concat is undefined. concat is a method on an array or string.

instead use:

for (var attrname in b) { a1[attrname] = b[attrname]; }
Matt Harrison
  • 13,381
  • 6
  • 48
  • 66
0

a1 is an object and javascript object does not have a concat method.

Concat is available for strings and arrays

Lucky Soni
  • 6,811
  • 3
  • 38
  • 57