For readability purposes you can use:
alert(JSON.stringify(someArrayOrObj, '', 2));
More about JSON.stringify().
Example:
let user = {
name: "John",
age: 30,
roles: {
isAdmin: false,
isEditor: true
}
};
alert(JSON.stringify(user, "", 2));
/* Result:
{
"name": "John",
"age": 30,
"roles": {
"isAdmin": false,
"isEditor": true
}
}
*/