How to set variable in Script Task when Value is an Array

Hi Everyone,

I am trying to merge two array into one array of Object and Set this Object as Variable for further use.
Using Script Format “javascript” and script type “Inline script”.

below is the code that I was trying.

var A_Group = execution.getVariableTyped("A_Group", true).getValue()
var B_Group = execution.getVariableTyped("B_Group", true).getValue()
var groupList = new Array
for(var i=0; i<A_Group.length;i++){
    for(var j=0;j<B_Group.length;j++){
	   groupList.push({ 
        "A_Group"  : A_Group[i],
        "B_Group"  : B_Group[j]
    });
	}
}

execution.setVariable("GroupList", groupList);

But whenever flow reached this script it shows this error

500 Internal Server Error

{
    "type": "RestException",
    "message": "Cannot instantiate process definition Process_11qsgp3:3:0c411f07-4944-11eb-9f3b-5c80b61f42fc: 
	Cannot serialize object in variable 'GroupList': SPIN/DOM-XML-01030 Cannot create context"
}

Please, any lead will be helpful. Ask in comment if not clear.

Thank you !

Please check java - Modifying an ArrayList in Javascript results in serialization failure in Camunda - Stack Overflow