Functional implementation of sets in JavaScript