“new Set” is returning an empty set in nodejsRemove empty elements from an array in JavascriptHow to store Node.js deployment settings/configuration files?How can I update NodeJS and NPM to the next versions?Is there a way to get version from package.json in nodejs code?NodeJs, Mocha and Mongoosereturn URLs scraping a webpage with nodejsStream read returning empty in nodejsHow to execute a promise in nodejs with expressNodeJS return data from inside of request function | request moduleNodeJs API give destination path to product image

Using curl along jq

Smallest Guaranteed hash collision cycle length

Chain link speeds

Is there any good reason to write "it is easy to see"?

How to cope with regret and shame about not fully utilizing opportunities during PhD?

Jesus' words on the Jews

Conditional probability - sum of dice is even given that at least one is a five

Is Germany still exporting arms to countries involved in Yemen?

Does gravity affect the time evolution of a QM wave function?

Anabelian geometry ~ higher category theory

Does SQL Server allow (make visible) DDL inside a transaction to the transaction prior to commit?

How can dragons propel their breath attacks to a long distance

What are the implications of the new alleged key recovery attack preprint on SIMON?

How do I tell my supervisor that he is choosing poor replacements for me while I am on maternity leave?

51% attack - apparently very easy? refering to CZ's "rollback btc chain" - How to make sure such corruptible scenario can never happen so easily?

transfer visa to new passport

On studying Computer Science vs. Software Engineering to become a proficient coder

Effects of ~10atm pressure on engine design

Earliest use of "rookie"?

Water Level Detection Sensor 3.3 Volt vs. 5 Volt

Interior smooth regularity

Determine if a string only contains repetitions of a substring

Why does the Earth follow an elliptical trajectory rather than a parabolic one?

Would an 8% reduction in drag outweigh the weight addition from this custom CFD-tested winglet?



“new Set” is returning an empty set in nodejs


Remove empty elements from an array in JavascriptHow to store Node.js deployment settings/configuration files?How can I update NodeJS and NPM to the next versions?Is there a way to get version from package.json in nodejs code?NodeJs, Mocha and Mongoosereturn URLs scraping a webpage with nodejsStream read returning empty in nodejsHow to execute a promise in nodejs with expressNodeJS return data from inside of request function | request moduleNodeJs API give destination path to product image






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I was testing some websites using the below function with n, suddenly "new Set" started returning empty Array as the following:



function collectAllSameOriginAnchorsDeep(sameOrigin = true) 

const allElements = [];

// Some coding here

const filtered = allElements

// Some coding here

console.log(filtered) // The items are printed in the log probably


return Array.from(new Set(filtered)); // Nothing is getting returned!



If I replace the last line with return Array.from(filtered), then it works fine but I'm using "Set" to remove any repeated values.










share|improve this question
























  • How much length/size of your filtered array?

    – Santosh Shinde
    Mar 23 at 12:45












  • Not more than a 100 item only

    – Hatem Husam
    Mar 23 at 12:53











  • You can create set object in top and add elements one by one , so you will get filtered elements

    – Santosh Shinde
    Mar 23 at 12:56











  • developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/…

    – Santosh Shinde
    Mar 23 at 12:57











  • If you are using at the end then you need to convert back to array using array.from “ES6 — Set vs Array — What and when?” by Maya Shavin link.medium.com/UGFoKMd9hV

    – Santosh Shinde
    Mar 23 at 13:02

















0















I was testing some websites using the below function with n, suddenly "new Set" started returning empty Array as the following:



function collectAllSameOriginAnchorsDeep(sameOrigin = true) 

const allElements = [];

// Some coding here

const filtered = allElements

// Some coding here

console.log(filtered) // The items are printed in the log probably


return Array.from(new Set(filtered)); // Nothing is getting returned!



If I replace the last line with return Array.from(filtered), then it works fine but I'm using "Set" to remove any repeated values.










share|improve this question
























  • How much length/size of your filtered array?

    – Santosh Shinde
    Mar 23 at 12:45












  • Not more than a 100 item only

    – Hatem Husam
    Mar 23 at 12:53











  • You can create set object in top and add elements one by one , so you will get filtered elements

    – Santosh Shinde
    Mar 23 at 12:56











  • developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/…

    – Santosh Shinde
    Mar 23 at 12:57











  • If you are using at the end then you need to convert back to array using array.from “ES6 — Set vs Array — What and when?” by Maya Shavin link.medium.com/UGFoKMd9hV

    – Santosh Shinde
    Mar 23 at 13:02













0












0








0








I was testing some websites using the below function with n, suddenly "new Set" started returning empty Array as the following:



function collectAllSameOriginAnchorsDeep(sameOrigin = true) 

const allElements = [];

// Some coding here

const filtered = allElements

// Some coding here

console.log(filtered) // The items are printed in the log probably


return Array.from(new Set(filtered)); // Nothing is getting returned!



If I replace the last line with return Array.from(filtered), then it works fine but I'm using "Set" to remove any repeated values.










share|improve this question
















I was testing some websites using the below function with n, suddenly "new Set" started returning empty Array as the following:



function collectAllSameOriginAnchorsDeep(sameOrigin = true) 

const allElements = [];

// Some coding here

const filtered = allElements

// Some coding here

console.log(filtered) // The items are printed in the log probably


return Array.from(new Set(filtered)); // Nothing is getting returned!



If I replace the last line with return Array.from(filtered), then it works fine but I'm using "Set" to remove any repeated values.







node.js puppeteer






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 23 at 12:43







Hatem Husam

















asked Mar 23 at 12:33









Hatem HusamHatem Husam

379




379












  • How much length/size of your filtered array?

    – Santosh Shinde
    Mar 23 at 12:45












  • Not more than a 100 item only

    – Hatem Husam
    Mar 23 at 12:53











  • You can create set object in top and add elements one by one , so you will get filtered elements

    – Santosh Shinde
    Mar 23 at 12:56











  • developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/…

    – Santosh Shinde
    Mar 23 at 12:57











  • If you are using at the end then you need to convert back to array using array.from “ES6 — Set vs Array — What and when?” by Maya Shavin link.medium.com/UGFoKMd9hV

    – Santosh Shinde
    Mar 23 at 13:02

















  • How much length/size of your filtered array?

    – Santosh Shinde
    Mar 23 at 12:45












  • Not more than a 100 item only

    – Hatem Husam
    Mar 23 at 12:53











  • You can create set object in top and add elements one by one , so you will get filtered elements

    – Santosh Shinde
    Mar 23 at 12:56











  • developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/…

    – Santosh Shinde
    Mar 23 at 12:57











  • If you are using at the end then you need to convert back to array using array.from “ES6 — Set vs Array — What and when?” by Maya Shavin link.medium.com/UGFoKMd9hV

    – Santosh Shinde
    Mar 23 at 13:02
















How much length/size of your filtered array?

– Santosh Shinde
Mar 23 at 12:45






How much length/size of your filtered array?

– Santosh Shinde
Mar 23 at 12:45














Not more than a 100 item only

– Hatem Husam
Mar 23 at 12:53





Not more than a 100 item only

– Hatem Husam
Mar 23 at 12:53













You can create set object in top and add elements one by one , so you will get filtered elements

– Santosh Shinde
Mar 23 at 12:56





You can create set object in top and add elements one by one , so you will get filtered elements

– Santosh Shinde
Mar 23 at 12:56













developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/…

– Santosh Shinde
Mar 23 at 12:57





developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/…

– Santosh Shinde
Mar 23 at 12:57













If you are using at the end then you need to convert back to array using array.from “ES6 — Set vs Array — What and when?” by Maya Shavin link.medium.com/UGFoKMd9hV

– Santosh Shinde
Mar 23 at 13:02





If you are using at the end then you need to convert back to array using array.from “ES6 — Set vs Array — What and when?” by Maya Shavin link.medium.com/UGFoKMd9hV

– Santosh Shinde
Mar 23 at 13:02












1 Answer
1






active

oldest

votes


















0














Because Set receives iterable object as its input parameter, and will create set object respectively. Hence, we can construct a set from an array — but it will only include distinct elements from that array, aka no duplicate.



And of course, we can also convert a set back to array using Array.from() method.



let set = new Set([1,2,3]); // 1,2,3
let arr = Array.from(set);//[1,2,3]


So you need to convert set back to array , please check here to understand the difference between set and array.



Hope this will help you!






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55313751%2fnew-set-is-returning-an-empty-set-in-nodejs%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Because Set receives iterable object as its input parameter, and will create set object respectively. Hence, we can construct a set from an array — but it will only include distinct elements from that array, aka no duplicate.



    And of course, we can also convert a set back to array using Array.from() method.



    let set = new Set([1,2,3]); // 1,2,3
    let arr = Array.from(set);//[1,2,3]


    So you need to convert set back to array , please check here to understand the difference between set and array.



    Hope this will help you!






    share|improve this answer



























      0














      Because Set receives iterable object as its input parameter, and will create set object respectively. Hence, we can construct a set from an array — but it will only include distinct elements from that array, aka no duplicate.



      And of course, we can also convert a set back to array using Array.from() method.



      let set = new Set([1,2,3]); // 1,2,3
      let arr = Array.from(set);//[1,2,3]


      So you need to convert set back to array , please check here to understand the difference between set and array.



      Hope this will help you!






      share|improve this answer

























        0












        0








        0







        Because Set receives iterable object as its input parameter, and will create set object respectively. Hence, we can construct a set from an array — but it will only include distinct elements from that array, aka no duplicate.



        And of course, we can also convert a set back to array using Array.from() method.



        let set = new Set([1,2,3]); // 1,2,3
        let arr = Array.from(set);//[1,2,3]


        So you need to convert set back to array , please check here to understand the difference between set and array.



        Hope this will help you!






        share|improve this answer













        Because Set receives iterable object as its input parameter, and will create set object respectively. Hence, we can construct a set from an array — but it will only include distinct elements from that array, aka no duplicate.



        And of course, we can also convert a set back to array using Array.from() method.



        let set = new Set([1,2,3]); // 1,2,3
        let arr = Array.from(set);//[1,2,3]


        So you need to convert set back to array , please check here to understand the difference between set and array.



        Hope this will help you!







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 23 at 13:07









        Santosh ShindeSantosh Shinde

        3,90822950




        3,90822950





























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55313751%2fnew-set-is-returning-an-empty-set-in-nodejs%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Obelisk of Theodosius Contents History Description Notes Bibliography Further reading External links Navigation menuAge of spirituality : late antique and early Christian art, third to seventh centuryOver 60 picturesObelisks of the World41°00′21.24″N 28°58′31.43″E / 41.0059000°N 28.9753972°E / 41.0059000; 28.97539727724550-7235741376235741376

            밀양 대씨 역사 각주 함께 보기 둘러보기 메뉴밀양 대씨

            1973년 목차 사건 문화 탄생 사망 노벨상 달력 둘러보기 메뉴