first you can check console.log(typeof Object)
if the output is object then var {data}=object ie just destructure the object according to the object keys. and the function can be like this.
const abc=(str1,str2=null)=>{
var result=[];
result.push(str1);result.push(str2);
return result.join("");
}