JavaScript implementation of SET