Avatar of Howard Bash
Howard Bash
Flag for United States of America asked on

JavaScript Arrays and objects

I am getting back an object from a rest call which contains results from a SharePoint REST call.  The returned data has dups (which are indeed in the list).

I want to dedup the data and then return it to be used elsewhere.  It looks something like the following:

function DedupeList(flist) {
                var listlength = flist.length;
                var newObject=[];
                var currentID = flist.results[0].FID;
                newObject.push(flist.results[0])
                //
                for (var ptr=1; ptr<listlength; ptr++) {
                                if (flist.results[ptr].FID!=currentID) {
                                                newObject.push(flist.results[ptr]);
                                                currentID = flist.results[ptr].FID;
                                }
                }
                
                return newFilmsObject;                
}

Open in new window


The issue is I want to return an object like the passed in data set from the REST call and am not sure if the array I am using to build the deduped set will work.
JavaScriptREST

Avatar of undefined
Last Comment
Member_2_248744

8/22/2022 - Mon
Leonidas Dosas

Would you like to give us an object sample to see the structure of the object that you want to dedup?
ASKER CERTIFIED SOLUTION
Member_2_248744

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Member_2_248744

This question has been inactive for 14 days, with no comment from the author. Force Close this question, answer to code that gives a duplicate cleared array.
Your help has saved me hundreds of hours of internet surfing.
fblack61