Is it possible to export a featureset (resulting from a query) to a hosted feature layer in ArcGIS Online and/or an ArcGIS Enterprise Portal using ArcGIS JavaScript?
Potentially just need some clarification about what you're trying to do.
You can do a query against a feature layer and then just pipe those results into an ApplyEdits against another layer in your AGOL or Enterprise using Javascript if that's what you're asking.