I am currently working on a Javascript project where I need to quickly generate a unique group_ID for a non-empty array of distinct positive integers, such as:
var a = [1, 2, 5]
In this case, I would like to identify this array using a binary number: 0b11001 (i.e., a binary number says that elements 1, 2 and 5 are in the group and the other elements are absent). Here, the ordering doesn't matter so I would get the same group_ID === 0b11001 for [2, 1, 5] or [5, 1, 2].
I am wondering if there is a quick way to generate this ID using either native JS, or underscore/lodash?