I am trying to collect record Ids of changed records. Therefor I'm using aura:attribute type="Set". But whenever I add the same id twice, it will be twice in my set. As described in the documentation, there should be no duplicates. (Current Worakround is using type="Map").

<aura:attribute name="mySet" type="Set" default="[]" access="private" />


var recordId = "a0246000005mfR0AAI";
var mySet = cmp.get("v.mySet");

cmp.set("v.mySet", mySet);

var doublecheck = cmp.get("v.mySet");

Debug result:

doublecheck = Proxy {0: "a0246000005mfR0AAI", 1: "a0246000005mfR0AAI", length: 2}

Am I handling the set wrong, or does it just not work yet?

  • Have you tried using add instead of push?
    – Raul
    Dec 13, 2017 at 11:44
  • @RahulSharma Yep, it told me mySet.add is not a function
    – itsmebasti
    Dec 13, 2017 at 11:58

1 Answer 1


I think that the problem is in javascript when you are declaring mySet.

Try this:

var mySet = new Set(component.get("v.mySet"));

Edit: the best solution is

var changes = cmp.get("v.changes") || new Set();
  • 2
    Worked, thanks! But if this is the solution, type="Set" seems to be useless, if I have to take care myself. Btw. I was able to do it like this: var changes = cmp.get("v.changes") || new Set(); so the default [] seems not to do the right thing :/
    – itsmebasti
    Dec 13, 2017 at 11:55
  • 2
    [] is an array initializer, I wouldn't expect it to be equal to new Set() Dec 13, 2017 at 14:43
  • 1
    It seems to be weird. I also believe type="Set" should have taken care of duplicates itself. Any thoughts? Dec 13, 2017 at 18:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .