var arr = ["Label1", "Label2", "Label3", "Label4", "Label2"];
var arr = ["Label1", {"label": "Label2", "indexes": [1, 4]}, "Label3", "Label4"];
const result = Object
.entries(arr.reduce((acc, n, i) => ((acc[n] = acc[n] || []).push(i), acc), {}))
.map(([ label, indexes ]) => indexes.length > 1 ? { label, indexes } : label);