Is there a possible way to make union parts through negate all in client sided script?

The GeometryService API can be used on the client.