JSFiddle - React, Tailwind, and code Playground
by dshilkret
HTML
<div id="response">
Response
</div><br>
<div id="response2">
</div>
<input type="button" id="button" value="Get" />
<input type="button" id="clear" value="Clear" />
JavaScript
$('#button').click(function() {
var a2 = [{"columnGroup":"Custom Columns","description":"","displayName":"Compliance Asset Id","enforceUniqueValues":false,"hidden":false,"id": "418d7676-2d6f-42cf-a16a-e43d2971252a","indexed":false,"name":"ComplianceAssetId","readOnly":true,"required":false}]
var a1 = [
{
"column_id": "418d7676-2d6f-42cf-a16a-e43d2971252a",
"sys_id": "03daf8dfdb126b40bb8ee536ca961976"
}
]
var hash = Object.create(null);
a1.concat(a2).forEach(function(obj) {
hash[obj.column_id] = Object.assign(hash[obj.id] || {}, obj);
});
var a3 = Object.keys(hash).map(function(key) {
return hash[key];
});
//console.log(a1);
//console.log(a2);
document.getElementById("response2").innerHTML=JSON.stringify(a3[0]);
console.log(JSON.stringify(a3[0]));
});