I have 3 functions
const func1 = () => {
return 1
}
const func2 = () => {
return 1
}
const func3 = () => {
return 2
}
let arr = [func1, func2, func3]
how can I filter dublicates (func1
and func2
) from arr
, so that I will have something like this filteredArr=[()=>{return 1},()=>{return 2}]
?
tried to stringify each of them and then use if with eval but I want to filter the array without using eval
2
Answers
You can filter the array with an additional check inside, but this requires you to call the functions.
You could use lodash library (Docs here):