var arr = [0, 1, 2, 2, 3, 3, 5];
var a = 2, b = 3;
You can use
filter to get the values that occur twice.
var arr = [0, 1, 2, 2, 3, 3, 5]; var dups = arr.filter ( (v,i,a) => a.indexOf(v) < i ); console.log(dups);
In comments you stated you would only have doubles, but no values that occur more than twice. Note that the above would return a value more than once, if the latter would be the case.
This returns the values in an array, which is how you should work. To put them in separate values can be done as follows:
var [a, b, ...others] = dups;