j.AngularJs.Distinct

PHOTO EMBED

Wed Sep 22 2021 13:54:50 GMT+0000 (UTC)

Saved by @rick_m #javascript #angularjs

distinct: function (list, identifierFunc) {

                let result = [];

                const map = new Map();

                list.forEach(item => {
                    let id = identifierFunc(item).toUpperCase();
                    if (!map.has(id)) {
                        map.set(id, true);

                        result.push(item);
                    }
                });

                return result;
            }
content_copyCOPY

Utils.distinct(products, (item) => item.id);