//You can obtain the value of a custom attribute like shown below
//Pass the "AttributeName" as a parameter of the getAttribute method:
var messagesCount = item1.get_attributes().getAttribute("Messages");
}
</script>