Collecting the keys from array of objects and reducing it into a single array and removing duplicates

You could take directly a set without using another array of keys.

let data = [{ test1: "123", test2: "12345", test3: "123456" }, { test1: "123", test2: "12345", test3: "123456" }, { test1: "123", test2: "12345", test3: "123456" }, { test1: "123", test2: "12345", test3: "123456" }, { test1: "123", test2: "12345", test3: "123456" }],
    uniqueKeys = Array.from(
        data.reduce((r, o) => Object.keys(o).reduce((s, k) => s.add(k), r), new Set)
    );

console.log(uniqueKeys)


const data = [{"test1":"123","test2":"12345","test3":"123456"},{"test1":"123","test2":"12345","test3":"123456"},{"test1":"123","test2":"12345","test3":"123456"},{"test1":"123","test2":"12345","test3":"123456"},{"test1":"123","test2":"12345","test3":"123456"},];

const res = data.reduce((unique, item) => (Object.keys(item).forEach(key => unique.add(key)), unique), new Set);

console.log([...res]);
.as-console-wrapper {min-height: 100%}