If you wish to pass an array or an object. do something like this:
//page code
let array= ['some array'];
$w('#customelement').setAttribute('attribute-name',JSON.stringify(array));
//custom code attribute change hook:
if(name === 'attribute-name'){
const value = JSON.parse(newValue);
//continue from here with the value
}