Do you really need to do this on the client side? Union is a fairly heavy operation and might be better done on the server side.
Another API that may be useful is the ArcGIS Javascript API, although from what I can see I don't think it will do union without ArcGIS Server: http://help.arcgis.com/en/webapi/javascript/arcgis/