I probably would not do that, mostly because keeping track of the brackets and parentheses becomes a nightmare. The cleaner way to do it is to take the inline function definition out. So you end up with something like
MQTT_Array.forEach(doIt);
function doit(value,index) {
if (value > 5)
{
return msg;
}
else
{
return null;
}
}
And do the same thing again if there is a nested forEach()
required.