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
  • 13,082
  • 7
  • 49
  • 71

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,001
  • 6
  • 46
  • 64
0

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

Concat is available for strings and arrays

Lucky Soni
  • 6,636
  • 3
  • 35
  • 56