// helpers start
const compose = (fn1, fn2) => x => fn1(fn2(x));
const reduceByProp = prop => a =>
a.reduce((acc, curr) => ({ ...acc, [curr[prop]]: curr }), {});
const uniqByProp = prop => compose(Object.values, reduceByProp(prop));
// helpers end
// logic start
const uniqByLastname = uniqByProp('lastname')
const getUniqAndPrint = compose(console.log, uniqByLastname)
// logic end
// exec start
const arr = [
{
'name': 'anna',
'lastname': 'petrova'
},
{
'name': 'vika',
'lastname': 'ivanova'
},
{
'name': 'julia',
'lastname': 'petrova'
},
];
getUniqAndPrint(arr);
// exec end
Интерактивный пример