I need to merge two javascript object and set it to my global object. I'm using "Object.assign" method but it doesn't work.It works right when it called first time. But I need to merge each time my new object to the global object. But it doesnt work more first time ,it makes my global just same as last object.Do you know any other way to make it ? Thanks in advance :/
Javscript codes :
//global object
Admin.bufferCreateJSON={};
Admin.createBufferJSON=function(){
var B_name=$("#B_name").val();
var B_description=$("#B_description").val();
var B_bufferType=$("#bufferTypeSelect").val();
var bufferData={};
var common = {'name': B_name,'description': B_description};
bufferData=Object.assign(bufferData, common);
var bufferType={ 'bufferType[id]': B_bufferType}
//following codes works right
bufferData=Object.assign(bufferData, bufferType);
//Admin.bufferCreateJSON is my global variable
// But when I want to merge it to my global variable it doesnt work
Admin.bufferCreateJSON=Object.assign(Admin.bufferCreateJSON, bufferData);
//shows me just last one
console.log(Admin.bufferCreateJSON);
}