JavaScript Array Comparison (aka Set Comparison)
In JavaScript objects, keys are always strings, or converted into strings.  Therefore, all the elements of a1 and a2 will be compared as if they were stringified.  For example, compareSets(['true'], [true]) returns true.  I consider that to be unexpected behaviour that either needs to be fixed or documented.